
New Hamburger Button Animations
Before We Start to New Hamburger Button Animations
New Hamburger Button Animations can be used to animate a Cards Closing Button, Menu Closing Buttons, etc. and create user attractive UI components.
So if you are a person who wishes to develop a website, you have to know how to create animations properly. Check out our tutorial and you can learn this techniques and use it on your web development. Below sections shows how to develop this animations.
How to create? We are here to solve your problem. In this article we discuss how to create a hover effect animations. Before we start please read the below articles which easier you to understand the process, if you are new to development.
Step 1 – Add HTML
It’s too easy and simple. Just copy and paste below code in your HTML editor between <body> </body> tag as below.
<body>
<section class="three-column-grid">
<div class="hamburger classic">
<span class="line"></span>
<span class="line"></span>
<span class="line"></span>
</div>
<div class="hamburger left-arrow">
<span class="line"></span>
<span class="line"></span>
<span class="line"></span>
</div>
<div class="hamburger right-arrow">
<span class="line"></span>
<span class="line"></span>
<span class="line"></span>
</div>
<div class="hamburger slant">
<span class="line"></span>
<span class="line"></span>
<span class="line"></span>
</div>
<div class="hamburger minus">
<span class="line"></span>
<span class="line"></span>
<span class="line"></span>
</div>
<div class="hamburger plus">
<span class="line"></span>
<span class="line"></span>
<span class="line"></span>
</div>
</section>
</body>
Step 2 – Add CSS
Copy and paste below code in your HTML editor between <style></style> tag as below.
<style>
:root {
/* Hamburger Primary Scale.*/
--hamburger-scale: 3;
/* Hamburger Mobile Scale Create breakpoints as needed. */
--hamburger-mobile-scale: 1;
--hamburger-color: #dce7d9;
--hamburger-hover-color: #7dc16a;
--hamburger-color-active: #36f700;
--body-background-color: #17044b;
}
/* Hamburger Primary CSS */
.hamburger {
transform: scale(var(--hamburger-scale));
width: 50px;
cursor: pointer;
}
/* Hamburger Scoling Media Query */
@media (max-width: 980px) {
.hamburger {
transform: scale(var(--hamburger-mobile-scale));
}
}
.hamburger .line {
width: 50px;
height: 5px;
background-color: var(--hamburger-color);
display: block;
margin: 8px auto;
transition: all 0.3s ease-in-out;
}
/* Hamburger Color Active State */
.hamburger.is-active .line {
background-color: var(--hamburger-color-active);
}
.hamburger:hover .line {
background-color: var(--hamburger-hover-color);
}
/* // END PRIMARY CSS */
/* Hamburger Classic Variation */
.classic.is-active .line:nth-child(2) {
opacity: 0;
}
.classic.is-active .line:nth-child(1) {
transform: translateY(13px) rotate(45deg);
}
.classic.is-active .line:nth-child(3) {
transform: translateY(-13px) rotate(-45deg);
}
/* Hamburger Left Arrow Variation */
.left-arrow.is-active .line:nth-child(1),
.left-arrow.is-active .line:nth-child(3) {
width: 40px;
}
.left-arrow.is-active .line:nth-child(1) {
transform: translateX(-10px) rotate(-45deg);
}
.left-arrow.is-active .line:nth-child(3) {
transform: translateX(-10px) rotate(45deg);
}
/* Hamburger Right Arrow Variation */
.right-arrow.is-active .line:nth-child(1),
.right-arrow.is-active .line:nth-child(3) {
width: 40px;
}
.right-arrow.is-active .line:nth-child(1) {
transform: translateX(10px) rotate(45deg);
}
.right-arrow.is-active .line:nth-child(3) {
transform: translateX(10px) rotate(-45deg);
}
/* Hamburger Slant Variation */
.slant.is-active .line:nth-child(1) {
width: 30px;
}
.slant.is-active .line:nth-child(2) {
width: 40px;
}
.slant.is-active .line {
transform: rotate(30deg);
}
/* Hamburger Minus Sign Variation */
.minus.is-active .line:nth-child(1) {
opacity: 0;
transform: translateX(-100%);
}
.minus.is-active .line:nth-child(3) {
opacity: 0;
transform: translateX(100%);
}
/* Hamburger Plus Sign Variation */
.plus.is-active .line:nth-child(1) {
transform: translateY(13px);
}
.plus.is-active .line:nth-child(3) {
transform: translateY(-13px) rotate(90deg);
}
/* Demo layout */
.three-column-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: 1fr;
grid-column-gap: 10vw;
grid-row-gap: 10vw;
width: 60vw;
margin: 0 auto;
}
.three-column-grid .hamburger {
margin: 0 auto;
}
body {
width: 100vw;
height: 100vh;
margin: 0;
padding: 0;
background: var(--body-background-color);
display: flex;
align-items: center;
justify-content: center;
}
</style>
At the end we will have something like this. You can change fonts, colors, backgrounds and all things that you want. Enjoy it.
Step 3 – Add JavaScript
We use some external JS to this code. No need to worry about this, copy and paste below code to the bottom of <body></body> tag. Before </body> closing tag.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
Copy and paste below code in your HTML editor between <script></script> tag.
<script>
$(".hamburger").click(function() {
$(this).toggleClass("is-active");
});
</script>
Out Put


Video Tutorial
Please watch this video to better understand this tutorial and don’t forget to subscribe to our channel.
Help others to find out about this article on Social Media sites. If you have any doubt or any problem, don’t hesitate to contact us. Thereafter we will be able to help you and also make sure you bookmark our site on your browser.