仿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地址:18.218.155.139,归属地:俄亥俄州Dublin ,欢迎您的访问!

温馨提示 : 非特殊注明,否则均为李联华的博客原创文章,本站文章未经授权禁止任何形式转载
文章链接:https://www.ooize.com/imitation-ios13-button.html
订阅
提醒
guest
0 评论
内联反馈
查看所有评论
Loading...