I'm putting together a rough navbar using Twitter bootstrap.
There's a breakpoint at which the width of the device will cause the navbar items to collapse and show a menu button instead:
How can I change the breakpoint so the navbar collapses sooner? At the moment its able to break on to a new line when it comes up against the logo, which doesn't look too great:
I've tried a fix detailed here, but it seemed to break the collapsed menu (couldn't expand it again afterwards).
Here's the html:
<!-- navigation -->
<div class="navbar navbar-default navbar-static-top">
<div class="container-fluid">
<div class="navbar-header">
<button class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img class="ManeEventLogo" src="/img/ManeEventLogoWhite-Sm.png"></a>
</div>
<div class="collapse navbar-collapse navbar-responsive-collapse">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="/index.php">HOME</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">SERVICES <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="/services/cutting-styling/index.php">Cutting & Styling</a></li>
<li><a href="/services/coloring/index.php">Coloring</a></li>
<li><a href="/services/hair-straightening-relaxing/index.php">Permanent Hair Straightening & Relaxing</a></li>
<li><a href="/services/balmain-hair-extensions/index.php">Balmain Hair Extensions</a></li>
</ul>
<li>
<a href="/wedding-day/index.php">WEDDING DAY</a>
</li>
<li>
<a href="/expertise-team/index.php">THE EXPERTISE TEAM</a>
</li>
<li>
<a href="/photo-gallery/index.php">PHOTO GALLERY</a>
</li>
<li>
<a href="/blog/index.php">BLOG</a>
</li>
</ul>
</div>
</div>
</div>
To create a collapsible navigation bar, use a button with class="navbar-toggler", data-toggle="collapse" and data-target="#thetarget" . Then wrap the navbar content (links, etc) inside a div element with class="collapse navbar-collapse" , followed by an id that matches the data-target of the button: "thetarget".
For navbars that never collapse, add the . navbar-expand class on the navbar. For navbars that always collapse, don't add any . navbar-expand class.
Which version of bootstrap are you using? 3.1? Anyway, I need as well your css to help you to fix it, but generally:
@media (max-width: 1200px) {
.navbar-header {
float: none;
}
.navbar-left,.navbar-right {
float: none !important;
}
.navbar-toggle {
display: block;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}
.navbar-fixed-top {
top: 0;
border-width: 0 0 1px;
}
.navbar-collapse.collapse {
display: none!important;
}
.navbar-nav {
float: none!important;
margin-top: 7.5px;
}
.navbar-nav>li {
float: none;
}
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
.collapse.in{
display:block !important;
}
.navbar-nav .open .dropdown-menu {
position: static;
float: none;
width: auto;
margin-top: 0;
background-color: transparent;
border: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
}
The max width is the breakpoint. Copied from Bootply (with demo included there).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With