<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>switch</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: #e3a380;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.switch-button {
position: relative;
width: 80px;
height: 40px;
border-radius: 20px;
appearance: none;
background-color: #c6c6c6;
outline: none;
box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
transition: 0.5s;
}
.switch-button:checked {
background-color: #03a9f4;
}
.switch-button::before {
content: "";
position: absolute;
width: 40px;
height: 40px;
border-radius: 50%;
top: 0;
left: 0;
background-color: #fff;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
transition: 0.5s;
transform: scale(.9);
}
.switch-button:checked:before {
left: 40px;
}
</style>
</head>
<body>
<input class="switch-button" type="checkbox">
</body>
</html>
手搓switch开关
最新推荐文章于 2023-03-10 21:55:22 发布