Skip to content

CSS Button Animation


<!DOCTYPE html>
    <link rel="stylesheet" type="text/css" href="checkbox-9.css">

        <input type="checkbox" name="">
        <span class="check"></span>
        <span class="text on">ON</span>
        <span class="text off">OFF</span>


  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  font-family: sans-serif;
  background-color: #000;
label input[type="checkbox"]{
  opacity: 0;
  display: none;
label input[type="checkbox"]:checked ~ .check{
  border-color: #fff
  display: block;
  width: 40px;
  height: 20px;
  border:1px solid #222;
  border-radius: 40px;
  margin-right: 2px;
  transition: .5s;
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border:2px solid #000;
  box-sizing: border-box;
  transition: .5s;
  box-shadow: inset 0 0 0 1px #222;
  border-radius: 50%;
label input[type="checkbox"]:checked ~ .check:before{
  box-shadow: inset 0 0 0 1px #fff;
  background-color: #fff;
  display: block;
  position: absolute;
  top: 0;
  right: -40px;
  width: 40px;
  font-size: 20px;
  transition: .5s;
  font-weight: bold;
  color: #222;
  transform: translateY(20px);
  opacity: 0;
label input[type="checkbox"]:checked ~ .text.on{
  transform: translateY(0px);
  opacity: 1;
  color: #fff;
  transform: translateY(0px);
  opacity: 1;
label input[type="checkbox"]:checked ~{
  transform: translateY(-20px);
  opacity: 0;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: