Here is the problem. I took default navbar example from bootstrap side(https://v4-alpha.getbootstrap.com/components/navbar/). They show full size navbar in result, that can collapse, when screen gets smaller. But when I've inserted the code into my project, it shows this:
As you can see it is always collapsed. I tried a lot of other examples, but nothing workes. Here is the code:
<!DOCTYPE html>
<html>
<head>
<title>Test area</title>
<link rel="stylesheet" href="media/css/bootstrap.min.css">
</head>
<body>
<div class="header">
<div class="top-header">
<div class="container">
<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Navbar</a>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-item nav-link active" href="#">Home <span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="#">Features</a>
<a class="nav-item nav-link" href="#">Pricing</a>
<a class="nav-item nav-link disabled" href="#">Disabled</a>
</div>
</div>
</nav>
</div>
</div>
</div>
<script src="media/js/jquery.min.js"></script>
<script src="media/js/popper.min.js"></script>
<script src="media/js/bootstrap.min.js"></script>
</body>
</html>
You need to add the required meta tags as described here:
And use the correct css classes as described here
The navbar will collapse at the lg breakpoint
For anyone looking now the code now works with the current latest bootstrap.
Remember to hard-reload to verify the change!
The code you posted will only work on Bootstrap alpha 6, not beta. This is because the
navbar-toggleable*
classes have changed tonavbar-expand*
as of Bootstrap 4 beta.Bootstrap 4.0.0: https://www.codeply.com/go/0c0FC1Lrn2
Also see: Bootstrap 4 navbar layout works using CDN, breaks using downloaded code