My bootstrap navbar links are many, so it wraps (I think at 970px).
I don't want it to wrap, the width of the links in total are about 1020px. I've searched high and low for the answer :(
When I add a width of 1020px to .navbar .navbar-collapse
the nav bar is now a little off center.
How can I get it to be 1020px width
and stay centered?
.navbar .navbar-collapse {
text-align: center;
width:1020px;
}
Then how do I get the navbar to not wrap but to collapse for tablet?
Edit:
Here's the html - basically (link names removed).
<!-- NAVIGATION -->
<div class="container">
<!-- Fixed navbar -->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="#welcome">LINK 1</a></li>
<li><a href="#who">LINK 2</a></li>
<li><a href="#benefits">BLAH BLAH</a></li>
<li><a href="#outline">BLAH BLAH BLAH</a></li>
<li><a href="#package">THE BLAH BLAH BLAH</a></li>
<li><a href="#faq">BLAH</a></li>
<li><a href="#testimonials">BLAH BLAH BLAH</a></li>
<li><a href="#bonuses">BLAH</a></li>
<li><a href="#buy" class="buyNow">BLAH</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<!-- End Fixed navbar -->
</div>
Here's the additional css:
.navbar .navbar-nav {
display: inline-block;
float: none;
vertical-align: top;
}
.navbar .navbar-collapse {
text-align: center;
width:1024px;
white-space: nowrap;
border: 3px dotted #ff00ff;
}
/* navbar */
.navbar-default {
background-color: #f2b32a;
border-color: #C89321;
font-size: 13px;
letter-spacing: -0.9px;
}
/* link */
.navbar-default .navbar-nav > li > a {
color: #fff;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: #333;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus {
color: #555;
background-color: #E7E7E7;
}
.navbar-default .navbar-nav > .open > a,
.navbar-default .navbar-nav > .open > a:hover,
.navbar-default .navbar-nav > .open > a:focus {
color: #555;
background-color: #D5D5D5;
}
.navbar {
box-shadow: 1px 1px 3px #C89321;
/* visibility: hidden; */
}
.buyNow{
font-size: 19px;
}
Have you tried: white-space: nowrap; Also if you reduce your html/css to a minimum that still has a problem and post it - others will be able to check and confirm the solution.
Why 1020px and not a standard 1024px, you can decrease the font size a bit to see what happens. But there isn't really much I can help you with, without a screenshot
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.