加入收藏 | 设为首页 | 会员中心 | 我要投稿 辽源站长网 (https://www.0437zz.com/)- 云专线、云连接、智能数据、边缘计算、数据安全!
当前位置: 首页 > 服务器 > 系统 > 正文

纯CSS3代码实现switch滑动开关按钮效果

发布时间:2020-03-17 07:45:56 所属栏目:系统 来源:站长网
导读:副标题#e# XML/HTML Code复制内容到剪贴板 divclass=container divclass=bg_con inputid=checked_1type=checkboxclass=switch/ labelfor=checked_1/label /div /div css代码,:before负责颜色,:after是那个白色小圆点,切换时的过渡效果用css3的动画实现。
副标题[/!--empirenews.page--]

XML/HTML Code复制内容到剪贴板

<div class="container">  

        <div class="bg_con">  

            <input id="checked_1" type="checkbox" class="switch" />  

            <label for="checked_1"></label>  

        </div>  

    </div>  

css代码,:before负责颜色,:after是那个白色小圆点,切换时的过渡效果用css3的动画实现。

CSS Code复制内容到剪贴板

.switch{   

        display:none;   

    }   

    label{   

        position:relative;   

        display: block;   

        padding: 1px;   

        border-radius: 24px;   

        height: 22px;   

        margin-bottom: 15px;   

        background-color: #eee;   

        cursor: pointer;   

        vertical-align: top;   

        -webkit-user-select: none;   

    }   

    label:before{   

        content: '';   

        display: block;   

        border-radius: 24px;   

        height: 22px;   

        background-color: white;   

        -webkit-transform: scale(1, 1);   

        -webkit-transition: all 0.3s ease;   

    }   

    label:after{   

        content: '';   

        position: absolute;   

        top: 50%;     

        left: 50%;     

        margin-top: -11px;     

        margin-left: -11px;   

        width: 22px;   

        height: 22px;   

        border-radius: 22px;   

        background-color: white;   

(编辑:辽源站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

推荐文章
    热点阅读