I'm trying to get the CSS sorted for a pager. I have a div floated left for the page numbers, and one floated right for a small form containing controls to set how many items per page are displayed.
When the page is at full size the divs are far enough apart that it doesn't really matter, but when the page is resized so that the divs are almost touching, it's noticeable.
How do I modify my CSS or HTML so that the text is vertically aligned between the two divs?
This is what it currently looks like:
Also, the text isn't quite centered in each page number. How do I get this to work?
Relevant CSS:
ol.mini-form {
margin: 0;
padding: 0;
}
ol.mini-form li {
display: inline;
}
ol.pager-pages {
margin: 0.5em 0;
padding: 0.5em 0;
float: left;
}
ol.pager-pages li {
padding: 0.4em;
margin: 0.1em;
border: 1px solid #ccc;
text-align: center;
}
ol.pager-result {
padding: 0.4em;
float: right;
}
HTML:
<div>
<ol class="mini-form pager-pages">
<li>
<a href="...">1</a>
</li>
<li>
<a href="...">2</a>
</li>
<li>
<a href="...">3</a>
</li>
</ol>
<form action="..." method="get">
<ol class="mini-form pager-result">
<li>
<select name="PageSize">
<option value="5">5</option>
<option selected="selected" value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
</select>
</li>
<li>
per page
</li>
<li>
<input type="submit" value="Set" />
</li>
</ol>
</form>
<div style="clear: both;"></div>
</div>
Thanks.
Does this work for you? http://jsfiddle.net/xPk9g/
Once you have block elements or floats wrapping the elements that should have the same baseline, you're screwed, and you will have to do the baseline manually by using line-height, margin or padding. Sometimes you can get around this by using display: inline-block
.
ol, li, form {
display: inline-block;
}
ol.mini-form {
margin: 0;
padding: 0;
}
ol.pager-pages {
margin: 0.5em 0;
padding: 0.5em 0;
width: 48%;
}
ol.pager-pages li {
padding: 0.4em;
margin: 0.1em;
border: 1px solid #ccc;
text-align: center;
}
form {
width: 45%;
text-align:right;
}
ol.pager-result {
padding: 0.4em;
}
<div>
<ol class="mini-form pager-pages">
<li>
<a href="...">1</a>
</li>
<li>
<a href="...">2</a>
</li>
<li>
<a href="...">3</a>
</li>
</ol>
<form action="..." method="get">
<ol class="mini-form pager-result">
<li>
<select name="PageSize">
<option value="5">5</option>
<option selected="selected" value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
</select>
</li>
<li>
per page
</li>
<li>
<input type="submit" value="Set" />
</li>
</ol>
</form>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With