Sat Sep 10 2022

Animated Hamburger Menu

CSS3338 views

Animated Hamburger Menu

File Name: animated-hamburger-menu.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Animated Hamburger Menu</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            background-color: #292929;
        }

        section {
            width: 100%;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        
        a.menu {
            display: flex;
            justify-content: center;
            align-items: center;
            width: 60px;
            height: 50px;
            position: relative;
            transition: 0.3s transform ease-in-out;
        }

        a.menu span {
            width: 60px;
            height: 2px;
            background-color: #fff;
            position: relative;
        }
        
        a.menu span::before,
        a.menu span::after {
            position: absolute;
            content: '';
            left: 0;
            height: 2px;
            width: 100%;
            background-color: #fff;
            transition: 0.2s transform ease-in-out;
            transform-origin: center right;
        }

        a.menu span::before {
            transform: translateY(-20px);
        }

        a.menu span::after {
            transform: translateY(20px);
        }

        a.menu:hover span::before {
            transform: scale(0.6) translateY(0px) rotate(45deg);
        }

        a.menu:hover span::after {
            transform: scale(0.6) translateY(0px) rotate(-45deg);
        }

        a.menu:hover {
            transform: rotate(90deg);
            transition-delay: 0.3s;
        }
    </style>
</head>
<body>
    <section>
        <a href="" class="menu">
            <span></span>
        </a>
    </section>
</body>
</html>

Result Screenshot(s)

Animated Hamburger MenuWorking Sample0

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.