iOS 11 UI Switch
by jorgeluis
HTML
<div class="switch">
<input type="checkbox" id="checkbox1" />
<label for="checkbox1">Make a checkbox look like an iOS switch</label>
</div>
SCSS
.switch {
input {
position: absolute;
display: block;
opacity: 0;
}
label {
position: relative;
display: inline-block;
min-height: 36px;
padding-top: 8px;
padding-left: 80px;
overflow: visible;
}
label::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 60px;
height: 34px;
display: inline-block;
cursor: pointer;
background: #fff;
border: solid 1px #ccc;
border-radius: 34px;
}
label::after {
content: '';
position: absolute;
left: 2px;
top: 2px;
width: 30px;
height: 30px;
background: #fff;
border-radius: 30px;
border: solid 1px #ccc;
box-shadow: -1px 2px 3px rgba(0, 0, 0, 0.2);
transition: left 0.2s, background-color 0.3s;
}
input:checked + label::before {
background: rgb(84, 206, 103);
border-color: rgb(84, 206, 103);
}
input:checked + label:after {
left: 28px;
border-color: #fff;
}
}