Netbyzz

#A095
on/off button animation

HTML :

<!-- CODE = #A095 -->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>NETBYZZ A095</title>
    <link rel="stylesheet" href="style.css">
  </head>
  <body>
      <label class="switch">
        <input type="checkbox" />
        <span class="slider"></span>
      </label>
  </body>
</html>

CSS :

.switch {
    margin-left: 50%;
    margin-top: 25%;
    font-size: 17px;
    position: relative;
    display: inline-block;
    width: 3.5em;
    height: 2em;
}

/* Hide default HTML checkbox */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* The slider */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    box-shadow: inset 2px 5px 10px rgba(0, 0, 0, 0.3);
    transition: 0.4s;
    border-radius: 5px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 1.4em;
    width: 0.1em;
    border-radius: 0px;
    left: 0.3em;
    bottom: 0.3em;
    background-color: white;
    transition: 0.4s;
}

input:checked+.slider {
    background-color: #171717;
    box-shadow: inset 2px 5px 10px rgb(0, 0, 0);
}

input:checked+.slider:before {
    transform: translateX(2.8em) rotate(360deg);
}

Source Code