Dremendo Tag Line

CSS Mega Menu

Navigation

In this lesson, we will learn how to create a mega menu using HTML and CSS.

Creating a Mega Menu using HTML and CSS

A mega menu in CSS is an expanded and enhanced version of a traditional dropdown menu. It is a user interface element that displays a large and often multi-level menu with various options and content, typically in a column-based layout.

video-poster
Example
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>Mega Menu</title>

    <!-- Internal CSS -->
    <style>
        .menu-bar {
            height: 45px;
            background-color: #1F2021;
            display: inline-block;
        }

        .menu {
            list-style-type: none;
            padding: 0;
            margin: 0;
        }

        .menu li {
            float: left;
        }

        .menu li a {
            display: block;
            line-height: 45px;
            padding: 0 15px;
            text-decoration: none;
            color: #BEBEBE;
        }

        .menu li a:hover {
            background-color: #004571;
            color: white;
        }

        .mega-menu {
            position: absolute;
            display: inline-block;
            background-color: #04214E;
            display: none;
        }

        .mega-menu ul {
            list-style-type: none;
            padding: 0;
            float: left;
            margin-right: 20px;
        }

        .mega-menu li {
            float: none;
        }

        .menu li:hover .mega-menu {
            display: block
        }

        .menu li:hover .mega-menu-div {
            background-color: #004571;
            color: white;
        }
    </style>
</head>

<body>
    <nav class="menu-bar">
        <ul class="menu">
            <li><a href="#">Home</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#" class="mega-menu-div">Products</a>
                <div class="mega-menu">
                    <ul>
                        <li><a href="#">Menu Item 1</a></li>
                        <li><a href="#">Menu Item 2</a></li>
                        <li><a href="#">Menu Item 3</a></li>
                        <li><a href="#">Menu Item 4</a></li>
                        <li><a href="#">Menu Item 5</a></li>
                    </ul>
                    <ul>
                        <li><a href="#">Menu Item 1</a></li>
                        <li><a href="#">Menu Item 2</a></li>
                        <li><a href="#">Menu Item 3</a></li>
                        <li><a href="#">Menu Item 4</a></li>
                        <li><a href="#">Menu Item 5</a></li>
                    </ul>
                    <ul>
                        <li><a href="#">Menu Item 1</a></li>
                        <li><a href="#">Menu Item 2</a></li>
                        <li><a href="#">Menu Item 3</a></li>
                        <li><a href="#">Menu Item 4</a></li>
                        <li><a href="#">Menu Item 5</a></li>
                    </ul>
                </div>
            </li>
            <li><a href="#">Services</a></li>
            <li><a href="#">Query</a></li>
            <li><a href="#">Contact</a></li>
        </ul>
    </nav>
</body>

</html>