zoukankan      html  css  js  c++  java
  • CSS/HTML实现Switch开关按钮

    原文链接:https://blog.csdn.net/yang031997/article/details/102944791

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <style>
            /* Switch开关样式 */
            input[type='checkbox'].switch {
                outline: none;
                appearance: none;
                -webkit-appearance: none;
                -moz-appearance: none;
                position: relative;
                width: 40px;
                height: 20px;
                background: #ccc;
                border-radius: 10px;
                transition: border-color .3s, background-color .3s;
            }
    
            input[type='checkbox'].switch::after {
                content: '';
                display: inline-block;
                width: 1rem;
                height: 1rem;
                border-radius: 50%;
                background: #fff;
                box-shadow: 0, 0, 2px, #999;
                transition: .4s;
                top: 2px;
                position: absolute;
                left: 2px;
            }
    
            input[type='checkbox'].switch:checked {
                background: rgb(19, 206, 102);
            }
    
            /* 当input[type=checkbox]被选中时:伪元素显示下面样式 位置发生变化 */
            input[type='checkbox'].switch:checked::after {
                content: '';
                position: absolute;
                left: 55%;
                top: 2px;
            }
        </style>
    </head>
    
    <body>
        <input type="checkbox" class="switch">
    </body>
    
    </html>
  • 相关阅读:
    php基础
    MYSQL 常用函数
    MYSQL 练习题
    MYSQL 查询
    MYSQL:增删改
    隐藏导航
    分层导航
    图片轮播!
    你帅不帅?
    PHP 流程
  • 原文地址:https://www.cnblogs.com/sangzs/p/13391768.html
Copyright © 2011-2022 走看看