Bootstrap snippet and html example. Animated hamburger sidebar menu

Bootstrap 4.6.0 snippet "Animated hamburger sidebar menu" with HTML, CSS, and JS. Copy, paste, and customize this responsive UI component for your project.

HTML code

Clean, semantic HTML that powers this Bootstrap 4.6.0 snippet. Copy and paste it into your page (with Bootstrap loaded) to reproduce the exact layout shown in the preview.

<!DOCTYPE html>
<html lang="en">
<head>
    <title></title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"/>
</head>
<body>
<div class="container">
    <div class="py-3">
        <div data-trigger="mobile-menu-toggle">
            <span>MENU</span>
            <button class="btn">
                <span></span>
                <span></span>
                <span></span>
            </button>
        </div>
    </div>
</div>
<aside class="menu">
    <ul>
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
        <li><a href="#">Link</a></li>
    </ul>
</aside>
</body>
<div style="position: fixed;bottom: 5%;right: 5%;">
    <h5 style="margin-bottom: 1rem;padding-bottom: 1rem;border-bottom: 1px solid #000;text-align: center;">Support my work @ MMLTech</h5>
    <div style="display: flex;align-items: center;">
        <a style="margin-right:1rem;background: #d1e6fd;display: block;padding: 1rem;border-radius: 0.25rem;border: 1px solid #e9ecef;color: #000;font-weight: bold;" href="https://ko-fi.com/mmltech" target="_blank"><img src="https://storage.ko-fi.com/cdn/Kofi_Logo_Blue.svg" width="60px"/> Buy me a coffee</a>
        <a style="background: #d1e6fd;display: block;padding: 1rem;border-radius: 0.25rem;border: 1px solid #e9ecef;color: #000;font-weight: bold;" href="https://obscountdown.com" target="_blank"><img src="https://streamcd.net/Assets/images/logo-white.png" width="60px" height="19px" /> My projects</a>
    </div>
</div>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</html>

CSS code

Scoped CSS that styles the component. Paste it after Bootstrap 4.6.0 to keep the design, spacing, and responsiveness consistent.

aside.menu{
            width: 300px;
            position: fixed;
            top:0;
            left: -200%;
            bottom: 0;
            background: #3c1874;
            -webkit-transition: .5s all;
            -moz-transition: .5s all;
            -ms-transition: .5s all;
            -o-transition: .5s all;
            transition: .5s all;
            z-index: 99;
        }
        .toggled aside.menu{
            left:0;
        }
        [data-trigger=mobile-menu-toggle] {
            /*display: none;*/
            display: flex;
            margin-bottom: 1rem;
            border-radius: 0.25rem;
            background: #3c1874;
            justify-content: space-between;
            align-items: center;
            padding: 1rem;
            position: sticky;
            top: 0;
            z-index: 9;
        }
        [data-trigger=mobile-menu-toggle] > span {
            font-weight: bold;
            font-size: 24px;
            color:#fff;
        }
        /*@media only screen and (max-width: 991px) {
            [data-trigger=mobile-menu-toggle] {
                display: flex;
            }
        }*/
        [data-trigger=mobile-menu-toggle] button {
            position: relative;
            display: flex;
            width: 50px;
            height: 40px;
            padding: 10px 0;
            flex-direction: column;
            justify-content: space-between;
            align-items: center;
            background: none;
            border:1px solid #fff;
        }
        [data-trigger=mobile-menu-toggle] button span {
            -webkit-transform: none;
            -moz-transform: none;
            -ms-transform: none;
            -o-transform: none;
            transform: none;
            -webkit-transition: 0.3s all;
            -moz-transition: 0.3s all;
            -ms-transition: 0.3s all;
            -o-transition: 0.3s all;
            transition: 0.3s all;
            width: 20px;
            height: 2px;
            background: #fff;
        }
        [data-trigger=mobile-menu-toggle] button.toggled span {
            width: 20px;
            height: 2px;
        }
        [data-trigger=mobile-menu-toggle] button.toggled span:nth-child(1) {
            -webkit-transform: rotate(45deg);
            -moz-transform: rotate(45deg);
            -ms-transform: rotate(45deg);
            -o-transform: rotate(45deg);
            transform: rotate(45deg);
            width: 30px;
            position: absolute;
            top: 50%;
        }
        [data-trigger=mobile-menu-toggle] button.toggled span:nth-child(2) {
            opacity: 0;
            position: absolute;
        }
        [data-trigger=mobile-menu-toggle] button.toggled span:nth-child(3) {
            width: 30px;
            -webkit-transform: rotate(-45deg);
            -moz-transform: rotate(-45deg);
            -ms-transform: rotate(-45deg);
            -o-transform: rotate(-45deg);
            transform: rotate(-45deg);
            position: absolute;
            top: 50%;
        }
        .menu ul{
            list-style-type: none;
            margin:0;
            padding: 1rem 0;
        }
        .menu ul li a{
            display: flex;
            align-items: center;
            padding: .55rem;
            font-weight: bold;
            color: #fff;
            font-size: 14px;
            text-transform: uppercase;
            text-decoration: none!important;
        }
        .menu ul li a:before{
            content: '\>';
            font-weight: bold;
            margin-right: .55rem;
            -webkit-transition: .3s all;
            -moz-transition: .3s all;
            -ms-transition: .3s all;
            -o-transition: .3s all;
            transition: .3s all;
        }
        .menu ul li a:hover:before{
            margin-right: 1rem;
        }

Javascript/Jquery code

Lightweight JS to power any interactions this snippet needs. Drop it under your scripts (after Bootstrap 4.6.0) to mirror the live demo.

$(function () {
        $(document).on('click', '[data-trigger="mobile-menu-toggle"] button', function () {
            $('body').toggleClass('toggled');
            $(this).toggleClass('toggled');
        })
    }); 

Similar snippets

Bootstrap example and template. simple user profile presentation social

simple user profile presentation social

Bootstrap example and template. Complete User Profile Page for Bootstrap

Complete User Profile Page for Bootstrap

Bootstrap example and template. Login form with icon

Login form with icon

Bootstrap example and template. Meet our experts

Meet our experts

Bootstrap example and template. List of Features

List of Features

Bootstrap example and template. New comments and popular post list

New comments and popular post list

Bootstrap example and template. User Profile with tabs

User Profile with tabs

Bootstrap example and template. chat room

chat room

FAQ

How do I use this snippet?

Include Bootstrap 4.6.0, paste the HTML, add the CSS block, and include the JS (if any) to mirror the live preview.

Can I use it in commercial projects?

Yes. It’s free for personal and commercial work; check the snippets license for details.

Is it responsive?

Yes. It inherits the responsive grid and components from Bootstrap 4.6.0.

Bootstrap example and template. Animated hamburger sidebar menu

About this bootstrap example/template

Optimized for copy‑paste: clean HTML, scoped CSS, and minimal JS so you can ship production‑ready UI faster and keep designs consistent.

Mobile‑first and responsive by default. Tested across modern browsers to reduce polish time on your project.

Already trusted in 1.1K+ views. Reuse this snippet to speed up landing pages, dashboards, or onboarding flows.

Bootstrap 4.6.0

<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css'>

<script src='https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js'></script>

This code example is based on bootstrap 4.6.0 and the grid system of this framework

Responsive

Based on bootstrap framework makes all the layouts perfectly responsive for all devices

Crossbrowser compatibility

Tested on all major browsers, it works smoothly on all of them

Jquery plugins

Great built-in plugins with jquery framework, you can easy to change all declarations

semantic html 5

Built on html / css3 the code quality is really amazing

Simple Integration

This code example can be simply integrated on existing sites and new ones too, all you need to do is copy the code and start working