Skip to content
Advertisements

CSS Button – YES NO

HTML CODE:

<!DOCTYPE html>
<html>
<head>
    <title>page</title>
    <link rel="stylesheet" type="text/css" href="checkbox-8.css">
</head>
<body>
    
    <div class="checkbox-btn">
        <input type="checkbox" name="">
        <div><span class="slide"></span></div>
    </div>

</body>
</html>

CSS CODE:

body{
  margin: 0;
  padding: 0;
  background:#f3f3f3;
  font-family: sans-serif;
}
.checkbox-btn{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  width: 100px ;
  height: 40px;
}
.checkbox-btn input{
  position:absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor:pointer;
  opacity: 0;
  z-index: 1;
}
.checkbox-btn div{
  position:absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border:4px solid #000;
  border-radius: 4px;
  box-shadow: 0 10px 20px rgba(0,0,0,.5);
  box-sizing: border-box;
  overflow: hidden;
}
.checkbox-btn div .slide{
  position: absolute;
  top: -12%;
  left: -1%;
  width: 40px;
  height: 40px;
  background:#000;
  transition: .5s;
}
.checkbox-btn input:checked + div .slide{
  transform: translateX(55px);

}
.checkbox-btn div .slide:before{
  content: "ON";
  position: absolute;
  top: 7%;
  left: -60px;
  text-align: center;
  width: 60px;
  height: 85%;
  line-height: 35px;
  background-color: #00da00;
  font-weight: bold;
  color: #fff
}
.checkbox-btn div .slide:after{
  content: "YES";
  position: absolute;
  top: 7%;
  left:40px;
  text-align: center;
  width: 60px;
  height: 85%;
  line-height: 35px;
  background-color: #ff002d;
  font-weight: bold;
  color: #fff
}
Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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: