自定义一个switch开关

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>theSwitch</title>
        <style>
            .label-switch {    
            }
            #checkBox {
                display: none;
            }
            .checkBox {
                width: 52px;
                height: 32px;
                border-radius: 16px;
                box-sizing: border-box;
                background: #d8d8d8;
                position: relative;
            }
            #checkBox:checked + .checkBox {
                background: #00b4ff;
            }
            #checkBox:checked + .checkBox::before {
                transform: translateX(22px);
                transition-duration: 300ms;
            }
            .checkBox::before {                
                width: 28px;
                height: 28px;
                border-radius: 28px;
                background: #ffffff;
                position: absolute;
                top: 2px;
                left: 1px;
                content: " ";
                transform: scale(1);
                box-sizing: border-box;
                transform: translateX(0);
                transition-duration: 300ms;
            }            
        </style>
    </head>
    <body>
        <label class="label-switch">
            <input type="checkbox" />
            <div class="checkBox" for="checkBox"></div>
        </label>
    </body>
</html>

 

相关文章:

  • 2021-12-27
  • 2021-07-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2021-12-27
  • 2022-12-23
猜你喜欢
  • 2021-12-27
  • 2022-12-23
  • 2021-12-27
  • 2021-05-09
  • 2021-04-25
  • 2021-10-30
相关资源
相似解决方案