Attempting to recreate the design from Codepen using Bootstrap 4.
The current progress can be viewed in this Codepen (drop down with 2 columns), which is assisting with online tutorials.
Here's the HTML for the Navbar:
<nav class="navbar navbar-expand-lg navbar navbar-dark bg-primary">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav">
<li class="nav-item dropdown has-mega-menu">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true"
aria-expanded="false">Dropdown</a>
<div class="dropdown-menu">
<div class="px-0 container container-sm">
<div class="row">
<div class="col-6 col-md-x">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
<a class="dropdown-item" href="#">Or a link</a>
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
</div>
<div class="col-6 col-md-x">
<a class="dropdown-item" href="#">Something else here</a>
<a class="dropdown-item" href="#">Or a link</a>
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
<a class="dropdown-item" href="#">Or a link</a>
</div>
</div>
</div>
</div>
</li>
</ul>
</div>
</nav>
CSS styling:
@media screen and (min-width: 576px) {
.has-mega-menu .container-sm {
width: 540px;
}
}
@media screen and (min-width: 768px) {
.has-mega-menu .container-md {
width: 720px;
}
}
@media screen and (min-width: 992px) {
.has-mega-menu .container-lg {
width: 960px;
}
}
@media screen and (min-width: 1200px) {
.has-mega-menu .container-xl {
width: 1140px;
}
}
Encountering two issues:
- The design lacks responsiveness (two columns should stack on small screens)
- Desire for the megamenu to take full width of the navbar, similar to BS3 example, while being responsive