点击查看html编辑器说明文档

开关edit icon

|
|
Fork(复制)
|
|
作者:
用户fkxIv10
提交反馈
嵌入
设置
下载
HTML
格式化
支持Emmet,输入 p 后按 Tab键试试吧!
<head> ...
展开
</head>
<body>
            
             <input id="checkbox" type="checkbox">
 <label class="switch" for="checkbox">
     <div class="powersign"></div>
 </label>
        
</body>
CSS
格式化
            
            html {
  height: 100%;
}
body {
  height: 100%;
  background: #212121;
  display:flex;
  align-items: center;
  justify-content: center;
  
}

#checkbox {
  display: none;
}

.switch {
  position: relative;
  width: 70px;
  height: 70px;
  background-color: rgb(255, 5, 5);
  border-radius: 50%;
  z-index: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgb(255, 126, 126);
  box-shadow: 0px 0px 3px rgb(248, 248, 248) inset;
}

.powersign {
  position: relative;
  width: 30%;
  height: 30%;
  border: 4px solid rgb(248, 248, 248);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.powersign::before {
  content: "";
  width: 8px;
  height: 60%;
  background-color: rgb(248, 248, 248);
  position: absolute;
  top: -60%;
  z-index: 2;
}

.powersign::after {
  content: "";
  width: 3px;
  height: 60%;
  background-color: rgb(255, 5, 5);
  position: absolute;
  top: -60%;
  z-index: 3;
}

#checkbox:checked + .switch .powersign {
  border: 4px solid rgb(255, 255, 255);
  box-shadow: 0px 0px 10px rgb(151, 243, 255),
    0px 0px 5px rgb(151, 243, 255) inset;
}

#checkbox:checked + .switch .powersign::after {
  background-color: rgb(150, 255, 194);
}

#checkbox:checked + .switch {
  box-shadow: 0px 0px 1px rgb(150, 255, 194) inset,
    0px 0px 2px rgb(150, 255, 194) inset,
    0px 0px 10px rgb(150, 255, 194) inset,
    0px 0px 40px rgb(150, 255, 194),
    0px 0px 100px rgb(150, 255, 194),
    0px 0px 5px rgb(150, 255, 194);
  border: 2px solid rgb(255, 255, 255);
  background-color: rgb(136, 219, 150);
}

#checkbox:checked + .switch .powersign::before {
  background-color: rgb(255, 255, 255);
}

        
JS
格式化
            
            
        
预览
控制台