Skip to content

Animation Checkbox

https://codepen.io/guldus/pen/RzQZmm?editors=1100

HTML

<div class='circle'>
  <div class='circle-mood'></div>
  <span class='line-short'></span>
  <span class='line-long'></span>
</div> 

CSS

.circle{
  width: 100px; height: 100px;
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
}
.circle-mood{
  width: 100%; height: 100%;
  border: 15px solid red;
  box-sizing: border-box;
  border-radius: 50%;
  transition: .5s;
  cursor: pointer;
}
.clicked{
  border: 50px solid green;
}
.line-short, .line-long{
  position: absolute; height: 10px;
  background: white;
  transition: .5s; opacity: 0;
}
.line-short{
  width: 30px; top: 55px; left: 25px;
  transform: rotate(45deg);
}
.line-long{
  width: 50px; top: 44px; left: 40px;
  transform: rotate(-45deg);
}
.clicked ~ .line-long{ 
  opacity: 1
}
.clicked ~ .line-short{
  opacity: 1
}

JS

$('.circle-mood').click(function () {
  $(this).toggleClass('clicked');
});

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: