I have implemented a Mega Menu using Bootstrap 5.
The menu is currently positioned on the left side due to the CSS styling:
@media (min-width: 992px)
.navbar-expand-lg .navbar-nav .dropdown-menu {
position: absolute;
}
If you'd like to see the Mega Menu constrained within the container element and centered, check out my example Mega Menu here:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Load Bootstrap 5 from CDN -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Load Bootstrap 5 JavaScript from CDN -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5/dist/js/bootstrap.bundle.min.js"></script>
<title>Bootstrap 5 MegaMenu Position Issue</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light shadow">
<!-- Navbar Content Goes Here -->
</nav>
<!-- Content -->
<div class="container">
<h1>Hello, world!</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit...</p>
</div>
</body>
</html>
The Mega Menu is currently absolutely positioned to the left. When changing the positioning to static, it jumps inside the nav itself.
Currently, setting `left:auto` in the CSS at a min-width of 992px results in the Mega Menu appearing on the right of the opening link:
@media (min-width: 992px)
.navbar-expand-lg .navbar-nav .dropdown-menu {
position: absolute;
left: auto;
}
For more details, click on this link: Mega Menu Example