Animated Full Screen Hamburger Menu in CSS

Animated Full Screen Hamburger Menu in CSS
Code Snippet:HTML and CSS Navigation Mastery
Author: Varun Kumar
Published: January 10, 2024
Last Updated: January 22, 2024
Downloads: 784
License: MIT
Edit Code online: View on CodePen
Read More

This code creates an Animated Full Screen Hamburger Menu in CSS. It works by using CSS and HTML to create a responsive navigation menu that expands and collapses when clicking a button. This menu is helpful for improving website navigation on smaller screens.

You can use this code for your website to create a stylish and responsive full-screen hamburger menu. It enhances user experience on mobile devices by providing an easily accessible navigation menu.

How to Create an Animated Full-Screen Hamburger Menu in CSS

1. Start by creating the HTML structure for your menu. You can use the following code as a template:

<h1>Crafted Elegance:  Elevating Your Website with Animated Navigation Using Checked Pseudo Elements</h1>
<h2>We can achieve this toggle effect using javascript event listner without using checked pseudo class and just using a button instead.</h2>

<div class="navigation">
    <input type="checkbox" class="navigation__checkbox" id="navi-toggle">
    <label for="navi-toggle" class="navigation__button">
      <span class="navigation__icon">&nbsp;</span>
    <div class="navigation__background"></div>
    <nav class="navigation__nav">
      <ul class="navigation__list">
        <li class="navigation__item"><a href="#" class="navigation__link">About</a></li>
        <li class="navigation__item"><a href="#" class="navigation__link">Home</a></li>
        <li class="navigation__item"><a href="#" class="navigation__link">Benefits</a></li>
        <li class="navigation__item"><a href="#" class="navigation__link">Plans</a></li>

Replace the sample links with your navigation links inside the <nav> element.

2. Copy and paste the following CSS code into your project. This code contains the styles needed to create the animated hamburger menu. Make sure to include it within the <style> tags in your HTML file or link to an external CSS file.

@import url('');

    box-sizing: border-box;

    box-sizing: inherit;

    font-size: 62.5%;

    height: 100vh;
    font-family: 'Roboto', sans-serif;
    font-size: 1.4rem;
    color: #fff;
    line-height: 1.42;
    background-color: black !important;
    margin: 0;
    overflow: hidden;

    color: #fff;
    padding: 20rem 8rem;

  padding: 0 3rem;
    display: none;

    background-color: #fff;
    height: 7rem;
    width: 7rem;
    position: fixed;
    top: 6rem;
    right: 6rem;
    border-radius: 50%;
    z-index: 100;
    box-shadow: 0 0.5rem 2rem rgba(155, 154, 154, 0.482);
    text-align: center;
    cursor: pointer;

    position: relative;
    margin-top: 3.5rem;

.navigation__icon, .navigation__icon::before, .navigation__icon::after{
    width: 3rem;
    height: 2px;
    background-color: black;
    display: inline-block;

.navigation__icon::before, .navigation__icon::after{
    content: "";
    position: absolute;
    left: 0;
    transition: all .2s;

    top: -.8rem;

    top: .8rem;

.navigation__button:hover .navigation__icon::before{
    top: -1rem;

.navigation__button:hover .navigation__icon::after{
    top: 1rem;

.navigation__checkbox:checked + .navigation__button .navigation__icon{
    background-color: transparent;

.navigation__checkbox:checked + .navigation__button .navigation__icon::before{
    top: 0;
    transform: rotate(135deg);

.navigation__checkbox:checked + .navigation__button .navigation__icon::after{
    top: 0;
    transform: rotate(-135deg);

/*Navigation Background*/

    height: 3rem;
    width: 3rem;
    position: fixed;
    top: 7rem;
    right: 7rem;
    opacity: 1;
    background-image: radial-gradient(rgba(4, 8, 1), rgba(41, 41, 40));
    z-index: 80;
    transition: transform .8s cubic-bezier(0.86, 0, 0.07, 1);

    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 90;

    opacity: 0;
    width: 0;
    transition: all 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);

    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    text-align: center;
    list-style: none;

    margin: 1rem;

.navigation__link:link, .navigation__link:visited{
    display: inline-block;
    font-size: 3rem;
    font-weight: 300;
    padding: 1rem 2rem;
    color: #fff;
    text-decoration: none;
    text-transform: uppercase;
    background-image: linear-gradient(120deg, transparent 0%, transparent 50%, #fff 50%);
    background-size: 250%;
    transition: all .4s;

.navigation__link:hover, .navigation__link:active{
    background-position: 100%;
    color: #000;
    transform: translateX(1rem);

.navigation__checkbox:checked ~ .navigation__background{
    transform: scale(100);

.navigation__checkbox:checked ~ .navigation__nav{
    opacity: 1;
    width: 100%;

You can customize the menu appearance by modifying the CSS styles. Adjust colors, sizes, and other properties to match your website’s design.

That’s all! hopefully, you have successfully created an animated fullscreen hamburger menu in your web/app project. If you have any questions or suggestions, feel free to comment below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About CodeHim

Free Web Design Code & Scripts - CodeHim is one of the BEST developer websites that provide web designers and developers with a simple way to preview and download a variety of free code & scripts. All codes published on CodeHim are open source, distributed under OSD-compliant license which grants all the rights to use, study, change and share the software in modified and unmodified form. Before publishing, we test and review each code snippet to avoid errors, but we cannot warrant the full correctness of all content. All trademarks, trade names, logos, and icons are the property of their respective owners... find out more...

Please Rel0ad/PressF5 this page if you can't click the download/preview link