I have a bunch of li's with hyperlinks in them. Here's a demo http://codepen.io/anon/pen/aOxJyr
<div class="collapse navbar-collapse" id="categorycollapse">
<ul id="Category" class="row list-inline nav navbar-nav">
<li>
<a href="/products/Category/Cars">
Cars
</a>
</li>
<li>
<a href="/products/Category/Cars%20R">
Cars R
</a>
</li>
<li>
<a href="/products/Category/Bus">
Bus
</a>
</li>
<li>
<a href="/products/Category/Bus">
Bus
</a>
</li>
<li>
<a href="/products/Category/Tempo">
Tempo
</a>
</li>
<li>
<a href="/products/Category/Cycle">
Cycle
</a>
</li>
<li>
<a href="/products/Category/Jet">
Jet
</a>
</li>
</ul>
</div>
I have used the following CSS for these list items to center align them. But it looks like some other css property is overriding my settings and the li's are left aligned instead. Check the bottom most row which is left-aligned.
#Category {
border:1px solid #C4C6C6;
margin: 0 60px 0 60px;
padding: 20px !important;
border-radius: 5px !important;
font-size: 12px !important;
text-align: center !important;
}
#Category > li {
font-family: 'Open Sans',sans-serif;
font-size: 14px;
font-weight: 400;
margin-top: 15px;
margin-left: 20px;
padding: 0 0 20px;
display: inline-block;
}
#Category li a, ol li a {
background-color: #07575B;
color: #FFFFFF;
transition: background .2s ease-in;
-o-transition: background .2s ease-in;
-moz-transition: background .2s ease-in;
-webkit-transition: background .2s ease-in;
padding: 10px 10px;
border-radius: 3px;
font-size: 14px !important;
display: inline !important;
}
How can I center align the list in a way that it overrides all css settings. With Center-align I mean if the elements span two rows, and the second row has only 3 elements, then those elements must be center-aligned and not left-aligned.
Update: Got it. The issue was with the attribute navbar-nav that I had applied on my Category which was left aligning the elements. I removed it.