Swith input - V2
by Bouteille Dimitri
HTML
<br/><br/>
<label class="material-switch">
<input type="checkbox" class="material-switch-input">
</label>
<br/><br/>
<label class="material-switch">
<input type="checkbox" class="material-switch-input" checked>
</label>
CSS
label, input {
margin: 0;
padding: 0;
}
.material-switch {
display: block;
width: 32px;
height: 16px;
cursor: default;
position: relative;
}
.material-switch-input {
visibility: hidden;
cursor: pointer;
width: inherit;
height: inherit;
transition: all 0.2s ease;
}
.material-switch-input:before, .material-switch-input:after {
transition: inherit;
content: "";
visibility: visible;
}
.material-switch-input:before {
border-radius: 50%;
background: #fafafa;
position: absolute;
transform-origin: center center;
top: 50%;
box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.12), 1px 1px 2px rgba(0, 0, 0, 0.24);
width: 20px;
height: 20px;
transform: translateY(-50%);
left: -4px;
}
.material-switch-input:after {
height: 100%;
background: #939393;
display: block;
border-radius: 8px;
}
.material-switch-input:checked:before {
left: calc(100% - 16px);
box-shadow: -1px 1px 3px rgba(0, 0, 0, 0.12), -1px 1px 2px rgba(0, 0, 0, 0.24);
background: #00E676;
}
.material-switch-input:checked:after {
background: rgba(0, 230, 118, 0.6);
}