jquery 实现开关按钮

HTML:

class="div1 open1"> class="left"> class="right">
class="div2 open2">
css:

.div1{
    width: 60px;
    height: 26px;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
}
.div1 .left{
    position: absolute;
    left:4px;
}
.div1 .right{
    position: absolute;
    right:4px;
}
.div2{
    width: 30px;
    height: 20px;
    border-radius: 9px;
    background: #fff;
    position: absolute;
}
.open1{
    background: #ddd;
}
.open2{
    top: 3px;
    left: 5px;
}
.close1{
    width: 60px;
    height: 26px;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
    background: #659dea;
}
.close2{
    left: 25px;
    top: 3px;
}
js:


效果图:

jquery 实现开关按钮_第1张图片

你可能感兴趣的:(jquery,css,移动端)