button toggle

In this example below you will see how to do a button toggle with some HTML / CSS and Javascript

This awesome code was written by bboyguil, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright bboyguil ©
  • HTML
  • CSS
<!DOCTYPE html>
<html lang="en" >

  <meta charset="UTF-8">
  <title>button toggle</title>
      <link rel="stylesheet" href="css/style.css">



  <input name="test" type="checkbox" id="test"><label class="la" for="test"></label>



/*Downloaded from https://www.codeseek.co/bboyguil/button-toggle-zRRNOv */

input:checked ~ .la:after{
  left: 40px;
input:checked ~ .la{
  box-shadow: -5px 0 0px red inset;
  margin: 100px auto;
  width: 100px;
  height: 40px;
  display: block;
  background: #aaa;
  background-size: 80px;
  border-radius: 50px;
  position: relative;
  transition: all .5s;
  box-shadow: -65px 0 0px red inset;
  content: "";
  position: absolute;
  top: 0px;
  left: 0;
  display: block;
  width: 60px;
  height: 40px;
  background: teal;
  border-radius: 50px;
  transition: all .5s;