I have this Bootstrap 5 megamenu and I want to make all the dropdown menus long all the page width and all have the same position.
Like this page.
How can I make the dropdown menus larger?
Which Bootstrap class do I have to modify?
I have tried but nothing has changed. I don't know why.
.navbar-nav {
max-width: 950px;
width: 80%;
display: flex;
justify-content: space-around;
align-items: center;
}
.navbar a:hover {
text-decoration: underline;
}
.dropdown-menu {
font-size: 0.8rem;
border: none;
text-align: center;
position: absolute;
border-radius: 0;
box-shadow: 0 10px 10px rgba(0, 0, 0, 0.1);
display: grid;
grid-template-columns: auto auto auto auto auto;
visibility: hidden;
width: 1225px;
z-index: 999;
}
#navbarSupportedContent {
display: flex;
justify-content: space-around;
}
.dropdown:hover .dropdown-menu {
visibility: visible;
}
.dropdown-menu.show {
display: flex;
}
.dropdown a:hover {
color: darkgrey;
text-decoration: none;
background-color: white;
}
.dropdown-menu li:first-child a {
color: darkgrey;
padding: 20px 0;
}
<!-- Bootstrap-5 Dependencies -->
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.8/dist/umd/popper.min.js" integrity="sha384-I7E8VVD/ismYTF4hNIPjVp/Zjvgyol6VFvRkX/vR+Vc4jQkC+hVqc2pM8ODewa9r" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<!-- Body -->
<nav id="navbar_top" class="navbar navbar-expand-lg">
<div class="container-fluid">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mb-2 mb-lg-0">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" role="button" aria-expanded="false">Lorem</a>
<div class="dropdown-menu">
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" role="button" aria-expanded="false">Lorem</a>
<div class="dropdown-menu">
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" role="button" aria-expanded="false">Lorem</a>
<div class="dropdown-menu">
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" role="button" aria-expanded="false">Lorem</a>
<div class="dropdown-menu">
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="" role="button" aria-expanded="false">Lorem</a>
<div class="dropdown-menu">
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
<ul>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
<li><a class="dropdown-item" href="">Lorem Ipsum</a></li>
</ul>
</div>
</li>
</ul>
</div>
</div>
</nav>
You can do it like this:
https://jsfiddle.net/SaoudiH/u9bpryzo/7/
You need to add these two classes:
.navbar .has-megamenu{position:static!important;}
.navbar .megamenu{left:0; right:0; width:100%; margin-top:0; }
Apply megamenu to the dropdown-menu element and has-megamenu to its parent.
Example:
<li class="nav-item dropdown has-megamenu">
<a class="nav-link dropdown-toggle" href="#" role="button" aria-expanded="false">Lorem</a>
<div class="dropdown-menu megamenu">
Check this resource: https://bootstrap-menu.com/detail-megamenu.html