Every time I click on the dropdown, it causes a vertical scroll instead of popping out like a regular dropdown. I want to maintain the horizontal scroll while fixing this issue.
Any suggestions on how to solve this problem?
Demo: https://jsfiddle.net/d3jy68q7/
HTML:
<nav class="navbar navbar-expand navbar-dark bg-dark">
<div class="container-fluid">
<div class="nav-scroller bg-body" id="navbarsExample03">
<ul class="nav navbar-nav me-auto mb-2 mb-sm-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" aria-disabled="true">Link 2</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" aria-disabled="true">Link 3</a>
</li>
<li class="nav-item">
<a class="nav-link" aria-disabled="true">Link 4</a>
</li>
<li class="nav-item">
<a class="nav-link" aria-disabled="true">Link 5</a>
</li>
<li class="nav-item">
<a class="nav-link" aria-disabled="true"&
gt;Link 6</a>
</li>
<li class="nav-item">
<a class="nav-link" aria-disabled="true"&
>Link7</a>
</li>
<li class="nav-item">
<a class="nav-link" aria-disabled="true"&
>Link8</a>
</li>
</ul>
</div>
</div>
</nav>
CSS:
.nav-scroller {
position: relative;
z-index: 2;
height: 2.75rem;
overflow-y: hidden;
background-color:#212529 !important;
}
.nav-scroller .nav {
display:flex;
flex-wrap:nowrap;
padding-bottom:1rem;
margin-top:-1px;
overflow-x:auto;
text-align:center;
white-space:nowrap;
-webkit-overflow-scrolling:touch;
}
.navbar nav.nav-link,.navbar-nav.nav-link.active,.navbar-nav.nav-link.show{
color:#fff;
}