开关按钮

<div class="switch-btn">
    <input type="checkbox" class="c1" />
    <div class="switch-inner">
        <div class="btn">
            <span class="active">ON</span>
            <span class="inactive">OFF</span>
        </div>
        <div class="arrow"></div>
    </div>
</div>
.switch-btn{
    position: relative;
    width: 60px;
    height: 30px;
    overflow: hidden;
}
.switch-btn .c1{
    position: absolute;
    top: 0;
    left: 0;
    width: 60px;
    height: 30px;
    opacity: 0;
    -moz-opacity: 0;
    -webkit-opacity: 0;
    cursor: pointer;
    z-index: 10;
}
.switch-btn .switch-inner{
    position: relative;
    height: 30px;
    border-radius: 13px;
    -moz-border-radius: 13px;
    -webkit-border-radius: 13px;
    background: #cccccc;
    transform: all 0.1s ease-in 0s ;
}
.switch-btn .switch-inner .btn{
    width:200%;
    height:30px;
    line-height:30px;
    margin-left:-100%;
    transition: margin 0.1s ease-in 0s;
}
.switch-btn .switch-inner .btn span{
    float: left;
    width: 50%;
    height: 30px;
    line-height: 30px;
    box-sizing:border-box;
    -moz-box-sizing:border-box; 
    -webkit-box-sizing:border-box; 
    font-size:12px;
}
.switch-btn .switch-inner .btn span.active{
    color:#FFFFFF;
    padding-right:26px;
    text-align:center;
}
.switch-btn .switch-inner .btn span.inactive{
    color:#FFFFFF;
    padding-left:26px;
    text-align:center;
}
.switch-btn .switch-inner .arrow {
    height:26px;
    width:26px;
    background:#FFFFFF;
    position:absolute;
    top:2px;
    right:32px;
    -moz-border-radius:100%; 
    -webkit-border-radius:100%; 
    border-radius:100%;
    transition: all 0.1s ease-in 0s;
}
.switch-btn .c1:checked + .switch-inner {
    background:#FFFF00;
}
.switch-btn .c1:checked + .switch-inner .btn {
    margin-left: 0;
}
.switch-btn .c1:checked + .switch-inner .arrow {
    right: 2px;
}

效果:
这里写图片描述
这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值