CSS3 + Transitions Slider toggle btn - andrew pougher
CSS3 + Transitions Slider toggle btn - andrew pougher
by Andrew Pougher
HTML
<div class="container"><div class="lead">Andrews Slide Btn</div><hr>
<div class="row">
<div class="col-md-12">
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch1" class="onoffswitch-checkbox" id="myonoffswitch1" checked>
<label class="onoffswitch-label" for="myonoffswitch1"></label>
</div>
<hr>
<div class="onoffswitch">
<input type="checkbox" name="onoffswitch2" class="onoffswitch-checkbox" id="myonoffswitch2" checked>
<label class="onoffswitch-label" for="myonoffswitch2"></label>
</div>
</div>
</div>
</div>
CSS
.onoffswitch {
position: relative; width: 30px;
-webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
}
.onoffswitch-checkbox {
display: none;
}
.onoffswitch-label {
display: block; overflow: hidden; cursor: pointer;
height: 13px; padding: 0; line-height: 13px;
border: 1px solid #999999; border-radius: 13px;
background-color: #D12626;
transition: background-color 0.3s ease-in;
}
.onoffswitch-label:before {
content: "";
display: block; width: 13px; margin: 0px;
background: #FFFFFF;
position: absolute; top: 0; bottom: 0;
right: 15px;
border: 1px solid #999999; border-radius: 13px;
transition: all 0.3s ease-in 0s;
}
.onoffswitch-checkbox:checked + .onoffswitch-label {
background-color: #69BD66;
}
.onoffswitch-checkbox:checked + .onoffswitch-label, .onoffswitch-checkbox:checked + .onoffswitch-label:before {
border-color: #69BD66;
}
.onoffswitch-checkbox:checked + .onoffswitch-label:before {
right: 0px;
}