Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mega menu dropdown with bootstrap 4
<nav class="navbar navbar-expand-sm">
<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 mx-auto">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Derpdown</a>
<div class="dropdown-menu">
<div class="px-0 container container-md">
<div class="row">
<div class="col-md-6">
<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-md-6">
<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>
<li class="nav-item">
<a class="nav-link" href="#" title="Link">Link</a>
</li>
</ul>
</div>
</nav>
.has-mega-menu{
position:static !important;
}
@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;
}
}
.navbar-toggler-icon {
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(0, 0, 0, 0.5)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 7h22M4 15h22M4 23h22'/%3E%3C/svg%3E");
}
.collapse.navbar-collapse.show .navbar-nav {
display: flex;
flex-flow: row wrap;
margin-bottom: 0;
justify-content: flex-start;
align-items: flex-start;
align-content: flex-start;;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.