滑动开关写法

效果


image.png
/*滑动开关*/
.switch{
    position: relative;
    -webkit-appearance: none;
    width:.9rem;
    height: .5rem;
    line-height: .5rem;
    background: #fefefe;
    border-radius: .3rem;
    outline: none;
    border: 1px solid #ddd;
}
.switch:before{
    position: absolute;
    left: 0;
    top:.025rem;
    content: '';
    width: .43rem;
    height: .43rem;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 2px #555;
    transition: all 0.2s linear;
}
.switch:checked{
    background: #31c8b6;
}
.switch:checked:before{
    left: .43rem;
    transition: all 0.2s linear;
}
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容