<!doctype html>
<html>
<head>
???<meta charset="utf-8">
???<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
???<meta name="viewport" content="width=device-width">
???<title>Examples</title>
???<meta name="description" content="">
???<meta name="keywords" content="">
<style>
*{margin:0;padding:0;}
body {background: #181818; } * {
box-sizing: border-box;
}
.cntr {
?position: absolute;
?top: 50%;
?left: 50%;
?transform: translate(-50%, -50%);
}
.hidden {
?display: none;
}
.switch-label {
?position: relative;
?display: block;
?height: 22px;
?width: 40px;
?background: #000;
?border-radius: 13px;
?cursor: pointer;
?border: 2px solid #404040;
?transition: all 0.2s ease;
}
.switch-label:after {
?position: absolute;
?left: -2px;
?top: -2px;
?display: block;
?width: 22px;
?height: 22px;
?border-radius: 100px;
?background: #a0a0a0;
?box-shadow: 0 1px 2px rgba(0,0,0,0.4);
?content: ‘‘;
?transition: all 0.3s ease;
}
.switch-label:active:after {
?width: 26px;
?background: #fff;
}
.switch-ipt:checked + label {
?background: #1db955;
?border-color: #1db955;
}
.switch-ipt:checked + label:after {
?left:16px;
?background: #fff;
}
.switch-ipt:checked + label:active:after {
?left:12px;
} ?
</style>
</head>
<body>
<div class="cntr">
?<input type="checkbox" id="switch-for" class="switch-ipt hidden"/>
?<label for="switch-for" class="switch-label"></label>
</div>
</body>
</html>
css 按钮
原文地址:https://www.cnblogs.com/dr-zhou/p/8868303.html