原开发者为:Coder 小何 提供非常感谢
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>switch(开关)</title>
</head>
<body>
<input type="checkbox" class="box1">
</body>
<style>
.box1{
width: 200px;
height: 100px;
background-color: rgb(78, 211, 129);
border-radius: 100px;
position: relative;
-webkit-appearance: none;
outline: none;
transition: 0.5s;
transform: rotate(180deg);
}
.box1::after{
content: "";
width: 98px;
height: 98px;
background-color: rgb(255, 255, 255);
border-radius: 50%;
position: absolute;
top: 50px;
margin-top: -49px;
left: 1px;
box-shadow: 2px 0px 3px 0px #cccccc;
-webkit-appearance: none;
outline: none;
transition: 0.5s;
}
.box1:checked{
background-color: rgb(110, 108, 108);
}
.box1:checked::after{
left: 100px;
}
</style>
</html>