How do I get a div to float to the bottom of its container?
Set the parent div to position: relative, then the inner div to… position: absolute; bottom: 0; …and there you go ๐
Set the parent div to position: relative, then the inner div to… position: absolute; bottom: 0; …and there you go ๐
The easiest is to put overflow:hidden on the parent div and don’t specify a height: #parent { overflow: hidden } Another way is to also float the parent div: #parent { float: left; width: 100% } Another way uses a clear element: <div class=”parent”> <img class=”floated_child” src=”https://stackoverflow.com/questions/2062258/…” /> <span class=”clear”></span> </div> CSS span.clear { clear: … Read more
I won’t be explaining how the floats work here (in detail), as this question generally focuses on Why use clear: both; OR what does clear: both; exactly do… I’ll keep this answer simple, and to the point, and will explain to you graphically why clear: both; is required or what it does… Generally designers float … Read more
Removing floats, and using inline-block may fix your problems: .pagination a { – display: block; + display: inline-block; width: 30px; height: 30px; – float: left; margin-left: 3px; background: url(/images/structure/pagination-button.png); } (remove the lines starting with – and add the lines starting with +.) .pagination { text-align: center; } .pagination a { + display: inline-block; width: … Read more
With that CSS, put your divs like so (floats first): <div id=”container”> <div id=”left”></div> <div id=”right”></div> <div id=”center”></div> </div> P.S. You could also float right, then left, then center. The important thing is that the floats come before the “main” center section. P.P.S. You often want last inside #container this snippet: <div style=”clear:both;”></div> which will … Read more
Solution 1: The most reliable and unobtrusive method appears to be this: Demo: http://jsfiddle.net/SO_AMK/wXaEH/ HTML: <div class=”clearfix”> <div style=”float: left;”>Div 1</div> <div style=”float: left;”>Div 2</div> </div>โ CSS: .clearfix::after { content: ” “; display: block; height: 0; clear: both; } โWith a little CSS targeting, you don’t even need to add a class to the parent … Read more