废话不多说 代码如下
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
input[type="checkbox"]{
/* 浏览器兼容 */
-webkit-appearance:none;
-moz-appeaarance:none;
-o-appearance:none;
-ms-appearance:none;
appearance:none;
/* ================ */
width:100px;
height:40px;
border-radius: 20px;
border: 1px solid #222;
position: relative;
transition: 1s;
/* 去掉默认边框 */
outline: none;
}
input[type="checkbox"]::after{
position: absolute;
left: 1px;
top: 1px;
display: block;
content: "";
width: 36px;
height: 36px;
border-radius: 50%;
background-color: #55aa7f;
box-shadow: 0 0 4px rgba(0, 0, 0, .4);
transition: 1s;
}
input[type="checkbox"]:checked{
background-color: #2de;
}
input[type="checkbox"]:checked::after{
background-color: #aa55ff;
left: 61px;
}
</style>
</head>
<body>
<input type="checkbox" >
</body>
</html>