Fancy checkboxes
by trolleymusic
HTML
<h2>Checkboxes</h2>
<div class="slide">
<input type="checkbox">
<label></label>
</div>
<div class="slide">
<input type="checkbox">
<label></label>
</div>
CSS
div {
position: relative;
margin: 20px;
display: inline-block;
font-family: arial;
font-size: 10px;
font-weight: bold;
}
h2 {
margin: 20px;
margin-bottom: 0;
}
.slide {
width: 80px;
height: 20px;
/*background: orange;*/
border-radius: 20px;
}
.slide input {
background: orange;
position: absolute;
width: 100%;
height: 100%;
opacity: 0;
z-index: 100;
cursor: pointer;
}
.slide label {
border-radius: 20px;
background: orange;
position: absolute;
width: 100%;
height: 100%;
}
.slide input:checked ~ label,
.slide input:active ~ label{
background: blue;
}
.slide label:after {
display: block;
content: '';
position: absolute;
width: 28px;
height: 28px;
top: -4px;
left: -4px;
border-radius: 100%;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#e5e5e5));
box-shadow: 0 0 3px 1px rgba(0,0,0,0.2);
}
.slide input:checked ~ label:after,
.slide input:active ~ label:after{
left: 56px; /* 84-28 */
}
.slide input ~ label:before {
color: #fff;
content: 'Private';
display: block;
position: absolute;
top: 0;
line-height: 20px;
left: 0;
text-align: right;
width: 80px;
height: 20px;
padding: 0 10px;
box-sizing: border-box;
}
.slide input:checked ~ label:before,
.slide input:active ~ label:before {
content: 'Public';
text-align: left;
}