Skip to content

Instantly share code, notes, and snippets.

@MrProgramerShah
Created November 1, 2019 09:15
Show Gist options
  • Save MrProgramerShah/c1c48e6cd9978ac37f5d98e89a29c832 to your computer and use it in GitHub Desktop.
Save MrProgramerShah/c1c48e6cd9978ac37f5d98e89a29c832 to your computer and use it in GitHub Desktop.
Animation checkbox
<div class='circle'>
<div class='circle-mood'></div>
<span class='line-short'></span>
<span class='line-long'></span>
</div>
$('.circle-mood').click(function () {
$(this).toggleClass('clicked');
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
.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: .s; opacity: 0;
}
.line-short{
width: 30px; top: 55px; left: 20px;
transform: rotate(45deg);
}
.line-long{
width: 50px; top: 44px; left: 35px;
transform: rotate(-45deg);
}
.clicked ~ .line-long{
opacity: 1
}
.clicked ~ .line-short{
opacity: 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment