How to make animated menu icon using html

Hello friends, today we will be going to how do we Make Animated Menu Icon Using Html. I have posted many videos and articles before related to the JavaScript project, now this the something new that we are going to build.

Video Tutorial of How To Make Animated Menu Icon Using Html


As you have seen on the given video tutorial of  How To Make Animated Menu Icon Using Html, 

If you are feeling bored watching the given video tutorial of How To Make Animated Menu Icon Using Html then you can copy or download the given codes below:


How To Make Animated Menu Icon Using Html | Free Source Code

To create this program (Animated Menu Icon Using Html). First, you need to create two Files one HTML File and another one is CSS File. After creating these files just paste the following codes in your file.

In the first place, make a HTML document with the name of index.html and glue the given codes in your HTML record. Keep in mind, you've to make a document with .html extension.
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <title>Animated menu icon</title>
</head>
<body>
    <div class="menu-icon">
        <div class="line-1 no-animation"></div>
        <div class="line-2 no-animation"></div>
        <div class="line-3 no-animation"></div>
    </div>
    <script>
        const menu = document.querySelector('.menu-icon')
        const line_1 = document.querySelector('.line-1')
        const line_2 = document.querySelector('.line-2')
        const line_3 = document.querySelector('.line-3')
        menu.addEventListener('click', ()=>{
            menu.classList.toggle('active');
            line_1.classList.remove('no-animation');
            line_2.classList.remove('no-animation');
            line_3.classList.remove('no-animation');
        })
    </script>
</body>
</html>
Second, make a CSS record with the name of style.css and glue the given codes in your CSS document. Keep in mind, you've to make a record with .css extension.
*
{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body
{
    background: #3faf82;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}
.menu-icon {
    width: 80px;
    height: 52px;
    cursor: pointer;
    z-index: 50;
}
.menu-icon .line-1,
.menu-icon .line-2,
.menu-icon .line-3 {
    height: 8px;
    width: 100%;
    background-color: #fff;
    border-radius: 3px;
    box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.3);
    transition: background-color 0.2s ease-in-out;
}
.menu-icon .line-1 {
    animation: animate-line-1-rev 0.7s ease-in-out;
}
.menu-icon .line-2 {
    margin: 14px 0;
    animation: animate-line-2-rev 0.7s ease-in-out;
}
.menu-icon .line-3 {
    animation: animate-line-3-rev 0.7s ease-in-out;
}

.menu-icon.active .line-1 {
    animation: animate-line-1 0.7s cubic-bezier(0.3, 1, 0.7, 1) forwards;
}
.menu-icon.active .line-2 {
    animation: animate-line-2 0.7s cubic-bezier(0.3, 1, 0.7, 1) forwards;
}
.menu-icon.active .line-3 {
    animation: animate-line-3 0.7s cubic-bezier(0.3, 1, 0.7, 1) forwards;
}

.no-animation {
    animation: none !important;
}

@keyframes animate-line-1 {
    0% {
      transform: translate3d(0, 0, 0) rotate(0deg);
    }
    50% {
      transform: translate3d(0, 22px, 0) rotate(0);
    }
    100% {
      transform: translate3d(0, 22px, 0) rotate(45deg);
    }
}
@keyframes animate-line-2 {
    0% {
      transform: scale(1);
      opacity: 1;
    }
    100% {
      transform: scale(0);
      opacity: 0;
    }
}
@keyframes animate-line-3 {
    0% {
      transform: translate3d(0, 0, 0) rotate(0deg);
    }
    50% {
      transform: translate3d(0, -22px, 0) rotate(0);
    }
    100% {
      transform: translate3d(0, -22px, 0) rotate(135deg);
    }
}
@keyframes animate-line-1-rev {
    0% {
      transform: translate3d(0, 22px, 0) rotate(45deg);
    }
    50% {
      transform: translate3d(0, 22px, 0) rotate(0);
    }
    100% {
      transform: translate3d(0, 0, 0) rotate(0deg);
    }
}
@keyframes animate-line-2-rev {
    0% {
      transform: scale(0);
      opacity: 0;
    }
    100% {
      transform: scale(1);
      opacity: 1;
    }
}
@keyframes animate-line-3-rev {
    0% {
      transform: translate3d(0, -22px, 0) rotate(135deg);
    }
    50% {
      transform: translate3d(0, -22px, 0) rotate(0);
    }
    100% {
      transform: translate3d(0, 0, 0) rotate(0deg);
    }
}
That’s all, now you’ve successfully created a program to How To Make Animated Menu Icon Using Html & JavaScript. If your code doesn’t work or you’ve faced any error/problem, please download the source code files from the given download button. It’s free and a .zip file will be downloaded then you’ve to extract it.
Click on the following download button to download all source code files.


Download Now
Please Wait...
Direct Link click here.

1 Comments

How can I help you

Post a Comment

How can I help you

Post a Comment

Previous Post Next Post