AnimationsButtonsTutorials

Colorful Hamburger Icon Animations

Colorful Hamburger Icon Animations

Colorful Hamburger Icon Animations

Before We Start to Colorful Hamburger Icon Animations

Colorful Hamburger Icon Animations can be used to animate a Cards, 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>
<main class="row">
        <div class="hamburger">
            <span class="bar"></span>
            <span class="bar"></span>
            <span class="bar"></span>
        </div>
        <div class="hamburger">
            <span class="bar"></span>
            <span class="bar"></span>
            <span class="bar"></span>
        </div>
    </main>
</body>

Step 2 – Add CSS

Copy and paste below code in your HTML editor between <style></style> tag as below.

<style>
        :root {
            --main: #c0e1d1;
            --bg: #001f6f;
        }

        *,
        *::before,
        *::after {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }

        body {
            background: var(--bg);
            color: var(--main);
        }

        h1 {
            padding-top: 5%;
            text-align: center;
        }

        .row {
            display: flex;
            width: 80%;
            margin: 0 auto;
        }

        .hamburger {
            display: block;
            cursor: pointer;
            width: 80px;
            margin: 100px auto;
        }

        .bar {
            display: block;
            width: 80px;
            height: 10px;
            background: var(--main);
            margin: 10px auto;
            transition: 0.2s ease-in;
        }

        .active :first-child {
            transform: rotate(45deg) translate(14px, 14px);
        }

        .active :nth-child(2) {
            opacity: 0;
        }

        .active :last-child {
            transform: rotate(-45deg) translate(14px, -14px);
        }

        .responsive :first-child {
            transform: rotate(45deg) translate(14px, 14px);
        }

        .responsive :nth-child(2) {
            width: 0;
        }

        .responsive :last-child {
            transform: rotate(-45deg) translate(14px, -14px);
        }
    </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/jquery-3.7.1.js"></script>

Copy and paste below code in your HTML editor between <script></script> tag.

<script>
        $(".hamburger:first-of-type").click(function() {
            $(this).toggleClass("active");
        });
        $(".hamburger:last-of-type").click(function() {
            $(this).toggleClass("responsive");
        });
    </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.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button