Given the following HTML:
<div id="container">
<!-- Other elements here -->
<div id="copyright">
Copyright Foo web designs
</div>
</div>
I would like #copyright
to stick to the bottom of #container
.
Can I achieve this without using absolute positioning? If the float property supported a value of 'bottom' it seems that would do the trick, but unfortunately, it doesn't.
Here is an approach targeted at making an element with a known height and width (at least approximately) float to the right and stay at the bottom, while behaving as an inline element to the other elements. It is focused at the bottom-right because you can place it easily in any other corner through other methods.
I needed to make a navigation bar which would have the actual links at the bottom right, and random sibling elements, while ensuring that the bar itself stretched properly, without disrupting the layout. I used a "shadow" element to occupy the navigation bar's links' space and added it at the end of the container's child nodes.
You can indeed
align
the box to thebottom
without usingposition:absolute
if you know theheight
of the#container
using the text alignment feature ofinline-block
elements.Here you can see it in action.
This is the code:
Yes you can do this without
absolute
positioning and without usingtable
s (which screw with markup and such).DEMO
This is tested to work on IE>7, chrome, FF & is a really easy thing to add to your existing layout.
It effectively does what
float:bottom
would, even accounting for the issue pointed out in @Rick Reilly's answer!Link here.
HTML:
CSS:
Try this;
If you do not know the height of child block:
http://jsbin.com/ULUXIFon/3/edit
If you know the height of the child block add the child block then add padding-top/margin-top :