input[type=checkbox] {
  height: 0;
  width: 0;
  visibility: hidden;
}

.a label {

  cursor: pointer;
  text-indent: -9999px;
  width: 60px;
  height: 35px;
  background: grey;
  display: block;
  border-radius: 35px;
  position: relative;
}

.a label:after {
  content: '';
  position: absolute;
  top: 5px;
  left: 5px;
  width: 25px;
  height: 25px;
  background: #fff;
  border-radius: 25px;
  transition: 0.3s;
}

.e label {

  cursor: pointer;
  text-indent: -9999px;
  width: 60px;
  height: 35px;
  background: yellow;
  display: block;
  border-radius: 35px;
  position: relative;
}

.e label:after {
  content: '';
  position: absolute;
  top: 5px;
  right: 5px;
  width: 25px;
  height: 25px;
  background: #fff;
  border-radius: 25px;
  transition: 0.3s;
}

input:checked +.a label {

}

input:checked + .a label:after {
  left: calc(100% - 5px);
  transform: translateX(-100%);
}

.a label:active:after {
  width: 130px;
}

input:checked + .e label {

}

input:checked +.e label:after {
  right: calc(100% - 55px);
  transform: translateX(-100%);
}

.e label:active:after {
  width: 5px;
}

Comments

Popular posts from this blog

Script For Login, Logout and View Using PHP, MySQL and Bootstrap

Real-Time Web Interface to MQTT using Socket.io and Node.js

Customize radio buttons and checkboxes with CSS sprites