Reasonable navbar and inline-block display with Bootstrap
I created a justified navbar in Bootstrap 3. My problem is that when I add a display: inline-box to vertically align my elements, the hot and click area does not fill the width and height between the borders anymore (please bear with me, my english rusty).
HTML:
<div class="container">
<nav role="navigation" class="navbar-justified">
<div class="navbar-header">
<button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
<span class="sr-only">Menu produits</span>
<i class="fa fa-bars fa-2x"></i>
</button>
</div>
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav nav-justified">
<li><a href="#">Aliquam bibendum</a></li>
<li><a href="#">Aliquam</a></li>
<li><a href="#">Praesent eros ipsum</a></li>
<li><a href="#">Quisque</a></li>
<li><a href="#">Suspendisse id dapibus</a></li>
<li><a href="#">Nullam consectetur dictum</a></li>
<li><a href="#">Lorem</a></li>
<li><a href="#">Aliquam bibendum</a></li>
</ul>
</div>
</nav>
CSS
.nav-justified {
text-align: center;
}
.nav-justified > li > a {
color: #2f2f2f;
font-size: 12px;
display:inline-block;
vertical-align:middle;
}
@media (min-width: 768px) {
.nav-justified > li {
border-right: 1px solid #d5d5d5;
}
}
.nav-justified > li:last-child {
border-right: 0;
}
Here's a link to Bootply to see the code in action: http://www.bootply.com/Zkl1LHJr1v
+3
source to share
2 answers