Using Twitter Bootstrap 3.
I have a fixed navbar with the menu items aligned to the right by adding .pull-right to the ul inside the navbar-collapse div.
When the nav collapses on small screens and you click to open it, the nav items are not 100% width as they should be, but about 30% and pulled to the right.
Have fixed this with:
@media (max-width: 767px) {
.navbar-nav.pull-right { float: none!important; }
}
But wondering if there is a better way to do it.
Code for the navbar is:
<!-- Fixed navbar -->
<div class="navbar navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">
<img src="application/assets/img/main-logo.png" alt="">
</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav pull-right">
<li class="active"><a href="#">Menu 1</a></li>
<li><a href="#about">Menu 2</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Menu 3 <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Menu 4 <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
<li><a href="#about">Menu 5</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
I read the manual!!
Need to use .navbar-right instead of .pull-right which has the media query already built in to bootstrap.
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