As I venture into the world of web development, please forgive me if my queries seem elementary.
I am currently using Bootstrap 4 and have implemented a navbar
with a hamburger menu that hides the entire menu when the screen reaches a certain width. However, I wish to modify this so that individual menu elements hide within a "more" button one by one. Essentially, if only one menu option exceeds the space available, it should move to the "more" button.
Initially, I attempted to use JavaScript to adjust the screen width and make the last element disappear:
setInterval(okno, 25)
function okno() {
var a = window.innerWidth;
if (a < 1335) {
document.getElementById("kontakt").style.display = "none";
}
}
<nav class="navbar navbar-expand-xl navbar-light"
style="background-color:dimgrey;position:fixed;width:100%;z-index:100">
<button class="navbar-toggler" type="button" style="background:white;float:left !important" data-toggle="collapse"
data-target="#colapsibleNavbar">
<span class="navbar-toggler-icon" style="color:black !important"></span>
</button>
<div class="collapse navbar-collapse justify-content-center" id="colapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="kopysno.html">Strona Główna</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Aktualnosci.html">Aktualności</a>
</li>
<li class="nav-item">
<a class="nav-link" href="mapaokolicy.html">Mapa Okolicy</a>
</li>
<li class="nav-item">
<div class="dropdown">
<a class="dropdown-toggle" style="text-align:center;text-decoration:none" data-toggle="dropdown"
href="#">Informacje</a>
<div style="background-color:dimgrey" class="dropdown-menu">
<a class="dropdown-item" href="Historia.html">Historia</a>
<a class="dropdown-item" href="#">Geografia</a>
<a class="dropdown-item" href="#">Środowisko</a>
<a class="dropdown-item" href="#">Kartografia Archiwalna</a>
<a class="dropdown-item" href="#">Galeria Fotografii</a>
</div>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Filmy</a>
</li>
<li class="nav-item">
<a class="nav-link" href="dawnimieszkancy.html">Dawni Mieszkańcy</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Artykuły prasowe</a>
</li>
<li class="kontakt nav-item">
<a class="nav-link" href="kontakt.html">Kontakt</a>
</li>
</ul>
</div>
</nav>
Unfortunately, this approach does not yield the desired results, and I am unsure why. Can anyone provide assistance? Thank you in advance.