css写一个原生switch开关按钮

在这里插入图片描述










<!DOCTYPE html>
<html>
<head>
    <title>switch开关按钮</title>
    <style type="text/css">
#checked {
 width: 60px;
 position: relative;
 margin: 20px auto;
}
.labelBox {
 margin-bottom: 20px;
 background: #409eff;
 border-radius: 40px;
 width: 60px;
 position: relative;
 height: 32px;
}
.check {
 display: block;
 width: 30px;
 height: 30px;
 border-radius: 50%;
 background: #fff ;
 border: 1px solid #e5e5e5;
 position: absolute;
 top: 0px;
 left: 0px;
}
input[type=checkbox] {
 border: 0 none !important;
 clip: rect(1px,1px,1px,1px);
 height: 1px !important;
 overflow: hidden !important;
 position: absolute !important;
 width: 1px !important;
}

@keyframes labelON {
 0% {
  top: 0px;
  left: 0px;
 }    
 100% {
  top: 0px;
  left: 28px;
 }
}

更多内容请见原文,原文转载自:https://blog.csdn.net/weixin_44519496/article/details/120152358

 

posted @ 2022-08-08 17:56  忘川信使  阅读(228)  评论(0编辑  收藏  举报