Checkbox toggle switch

Pure CSS toggle switch for HTML checkboxes

by Luis Valle

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="fi-toggle-switch">
        <input type="checkbox" id="mycheckbox">
        <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%;
}
.fi-toggle-switch {
  display: inline-block;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  width: 40px;
  height: 21px;
  -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;
  border: 1px solid #2B669A;
}
.fi-toggle-switch input[type="checkbox"] {
  display: none;
}
.fi-toggle-switch input[type="checkbox"]:checked + label span {
  -webkit-transform: translate(34px, 0px);
  -moz-transform: translate(34px, 0px);
  -o-transform: translate(34px, 0px);
  transform: translate(34px, 0px);
  background: #f1f1f1;  
}
.fi-toggle-switch label {
  display: block;
  overflow: hidden;
  cursor: pointer;
  /*border: 1px solid #2B669A;*/
}
.fi-toggle-switch label span {
  display: inline-block;
  width: 40px;
  height: 21px;
  position: relative;
  background: #555555;
  left: -34px;
  -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;  
  
}
.fi-toggle-switch label span:before,
.fi-toggle-switch label span:after {
  display: block;
  position: absolute;
  width: 34px;
  height: 21px;
  padding: 0;
  line-height: 22px;
  font-size: 12px;
  color: black;
  font-family: Arial;
  font-style: normal;
  font-weight: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
.fi-toggle-switch label span:before {
  content: "ON"; /*\f00c*/
  color: white;
  justify-content: center;
  text-align: center;
  background-color: #3A7FBB;
  left: 0px;  
}
.fi-toggle-switch label span:after {
  content: "OFF";
  background-color: #E0E0E0;
  text-align: center;
  justify-content: center;
 ...