Reputation: 948
I have the following markup. I am trying to have "Previous" all the way to the left, "Next" all the way to the right, and the numbers centered. I can't seem to get the numbers centered.
I tried margin: 0 auto;
on .numbers
to no avail. The closest I've come was to set the left margin on .numbers
to something like 40%, but that seems hackish, because previous and next might not always be there, and there may be more or less than 4 numbers. I'm pretty flexible with the markup and css.
<div id="content">
<div class="pagination">
<div class="previous">Previous</div>
<div class="numbers">
<a href="#">1</a>
<a href="#">2</a>
<a href="#">3</a>
<a href="#">4</a>
</div>
<div class="next">Next</div>
<div class="clear"></div>
</div>
</div>
And
#content {
width: 100%;
border: 1px solid #000;
}
.previous, .numbers {
float: left;
}
.next {
float: right;
}
.clear {
clear: both;
}
Upvotes: 0
Views: 68
Reputation: 1205
If you want to use "margin: 0px auto" you also have to set a width for the div.
Upvotes: 1
Reputation:
Move div.next
to before div.numbers
in the markup, don't float .numbers
, and apply text-align: center
to .numbers
.
jSFiddle for those who don't think in css ;)
Upvotes: 2