仿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地址:3.141.201.95,归属地:俄亥俄州Dublin ,欢迎您的访问!
文章链接:https://www.lilianhua.com/imitation-ios13-button.html
Popup Image

通知

卡密兑换正式上线,并且网站不定时发放免费卡密,先到先得!卡密兑换界面:前往

Loading...