仿ios13按钮
HTML:
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" tabindex="0" checked>
<label class="onoffswitch-label" for="myonoffswitch"></label>
</div>
CSS:
.onoffswitch {
position: relative; width: 88px;
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
}
.onoffswitch-checkbox {
position: absolute;
opacity: 0;
pointer-events: none;
}
.onoffswitch-label {
display: block; overflow: hidden; cursor: pointer;
height: 26px; padding: 0; line-height: 26px;
border: 2px solid #E3E3E3; border-radius: 26px;
background-color: #FFFFFF;
transition: background-color 0.3s ease-in;
}
.onoffswitch-label:before {
content: "";
display: block; width: 26px; margin: 0px;
background: #FFFFFF;
position: absolute; top: 0; bottom: 0;
right: 60px;
border: 2px solid #E3E3E3; border-radius: 26px;
transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label {
background-color: #334BFF;
}
.onoffswitch-checkbox:checked + .onoffswitch-label, .onoffswitch-checkbox:checked + .onoffswitch-label:before {
border-color: #334BFF;
}
.onoffswitch-checkbox:checked + .onoffswitch-label:before {
right: 0px;
}
效果:
温馨提示 : 非特殊注明,否则均为©李联华的博客网原创文章,本站文章未经授权禁止任何形式转载;IP地址:44.222.82.133,归属地:弗吉尼亚州Ashburn ,欢迎您的访问!
文章链接:https://www.ooize.com/imitation-ios13-button.html
文章链接:https://www.ooize.com/imitation-ios13-button.html
订阅
登录
0 评论