Reputation: 793
I'm using bootstrap v3 & trying to align unordered list in the center of the container. For some reason it's not centered correctly
Here's the html
<!-- Page Content -->
<div class="container" style="border: 1px solid red">
<div class="row">
<div class="col-lg-12">
<ul id="tabs">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
</div>
<!-- /.row -->
</div>
<!-- /.container -->
and css
ul#tabs {
display: block;
margin: 0 auto;
}
ul#tabs li{
float: left;
border: 1px solid red;
width: 180px;
height: 80px;
padding:0;
margin:0;
}
What I'm doing wrong?
Upvotes: 0
Views: 1742
Reputation: 36965
margin: 0 auto;
won't center an element without specified width, because display:block
makes the element occupy all the available horizontal space.
Since your li
s are fixed width you could try:
ul#tabs {
display: block;
text-align:center;
}
ul#tabs li{
display:inline-block;
border: 1px solid red;
width: 180px;
height: 80px;
padding:0;
margin:0;
}
Keep in mind that the ul
is still as wide as its parent, so it may not be the best solution if you need a background on the ul
that covers only the area of combined li
s.
Upvotes: 1