Hello, so I am currently practice how to create a responsive navbar using bootstrap 4.xx and then I found this problem. The problem is, that burger button should only appear when the screen is small (around 768px)
So the first code is where I build from scratch which didn’t work at all, and the other one is from bootstrap documentations which is working.
Here’s my code
<nav class="navbar nav-expand-md navbar-light bg-light sticky-top">
<div class="container-fluid">
<a class="navbar-brand" href="#"
><img src="img/logo.png" alt="logo.png"
/></a>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarNavDropdown"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a href="#" class="nav-link">Home</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">About</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Services</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Team</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Connect</a>
</li>
</ul>
</div>
</div>
</nav>
And here’s the one from bootstrap documentation, I modified the content so it looks like mine
<nav class="navbar navbar-expand-md navbar-light bg-light sticky-top">
<div class="container-fluid">
<a class="navbar-brand" href="#"
><img src="img/logo.png" alt="logo.png"
/></a>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarNavDropdown"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a href="#" class="nav-link">Home</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">About</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Services</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Team</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Connect</a>
</li>
</ul>
</div>
</div>
</nav>
CMIIW, they are same! But different result. I’ve track all the line and found nothing.
Please help, thanks!
Btw, here’s the link to my code in case you need more information.