CSS Slider Switch
Slider on/off switch using CSS.
HTML
<label id="sliderLabel">
<input type="slider" />
<span id="slider"></span>
<span id="sliderOn">On</span>
<span id="sliderHalf">Half</span>
<span id="sliderOff">Off</span>
</label>
CSS
#sliderLabel {
border: 2px solid black;
-webkit-border-radius: 7px;
-moz-border-radius: 7px;
border-radius: 7px;
cursor: pointer;
display: block;
height: 30px;
margin: 20px auto;
overflow: hidden;
position: relative;
width: 80px;
}
#sliderLabel input {
display: none;
}
#sliderLabel input:checked + #slider {
left: 36px;
}
#slider {
background: #c0c6c3;
-moz-border-radius: 7px;
display: block;
height: 30px;
left: -4px;
position: absolute;
top: 0px;
-moz-transition: left .25s ease-out;
-webkit-transition: left .25s ease-out;
transition: left .25s ease-out;
width: 48px;
z-index: 1;
}
#sliderOn, #sliderOff {
color: white;
display: block;
font-family: verdana, arial, sans-serif;
font-size: 14px;
font-weight: bold;
line-height: 30px;
position: absolute;
text-align: center;
top: 0px;
width: 40px;
}
#sliderOn {
background: #002400;
background: -moz-linear-gradient(top, #002400 0%, #008a00 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#002400), color-stop(100%,#008a00));
background: -webkit-linear-gradient(top, #002400 0%,#008a00 100%);
background: -o-linear-gradient(top, #002400 0%,#008a00 100%);
background: -ms-linear-gradient(top, #002400 0%,#008a00 100%);
background: linear-gradient(top, #002400 0%,#008a00 100%);
left: 0px;
}
#sliderOff {
background: #870000;
background: -moz-linear-gradient(top, #870000 0%, #ff0000 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#870000), color-stop(100%,#ff0000));
background: -webkit-linear-gradient(top, #870000 0%,#ff0000 100%);
background: -o-linear-gradient(top, #870000 0%,#ff0000 100%);
background: -ms-linear-gradient(top, #870000 0%,#ff0000 100%);
background: linear-gradient(top, #870000 0%,#ff0000 100%);
right: 0px;
}