Checkbox toggle switch
Pure CSS toggle switch for HTML checkboxes
HTML
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css">
<div class="wrapper">
<!-- markup required for checkbox switch -->
<div class="switch">
<input type="checkbox" id="mycheckbox" checked>
<label for="mycheckbox"><span></span></label>
</div>
</div>
CSS
html,body {
margin: 0px;
height: 100%;
}
.wrapper {
background: #e6e8ea;
height: 100%;
text-align: center;
padding-top: 15%;
}
.switch {
display: inline-block;
cursor: pointer;
overflow: hidden;
position: relative;
width: 80px;
height: 30px;
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
border-radius: 0px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.switch input[type="checkbox"] {
display: none;
}
.switch input[type="checkbox"]:checked + label span {
-webkit-transform: translate(60px, 0px);
-moz-transform: translate(60px, 0px);
-o-transform: translate(60px, 0px);
transform: translate(60px, 0px);
background: #00436c;
}
.switch label {
display: block;
overflow: hidden;
cursor: pointer;
}
.switch label span {
display: inline-block;
width: 80px;
height: 30px;
position: relative;
background: #555555;
left: -60px;
-webkit-transition: all 0.15s ease-out;
-moz-transition: all 0.15s ease-out;
-o-transition: all 0.15s ease-out;
transition: all 0.15s ease-out;
}
.switch label span:before,
.switch label span:after {
display: block;
position: absolute;
width: 60px;
height: 30px;
padding: 0;
line-height: 30px;
font-size: 14px;
color: #ffffff;
font-family: FontAwesome;
font-style: normal;
font-weight: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-weight: bold;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.switch label span:before {
content: "Unlocked";
justify-content: center;
text-align: center;
background-color: #0a6aa6;
left: 0px;
}
.switch label span:after {
content: "Locked";
background-color: #a2a2a2;
text-align: center;
justify-content: center;
left: 80px;
}