If the sidebar fills up 100% of the page's height, you can create a wrapper that is absolute
positioned in the sidebar with the bottom
property set to 0px
.
This should look something like this:
.wrapper {
position: absolute;
bottom: 0;
}
And it's straight from this example. As another commenter already pointed out, you might have to change the static
positioning of the parent #sidebar
element.
To my knowledge this would be the only non-Javascript approach, but it will only work if the sidebar is at 100%.
Notable alternative option using JavaScript:
Let's say you know the heights of all the elements you are working with. You could then simply adjust the margin-top
property of div
element to be placed at the bottom.
This would look something like this:
window.onload = function() {
var header = document.getElementById("heading");
var bottom = document.getElementById("bottom");
var height = document.body.scrollHeight;
bottom.style.marginTop = (height - header.clientHeight) + 'px';
}
I hope this helps!
Edit:
Now that I think about this more, this is a perfect use case for the calc()
CSS3 function. You might want to check it out.
Using this has a few caveats, like if you don't know the height of the content in the bottom-positioned div
100% of the time or if you care about cross-compatibitly problems (although I would say it has pretty good support).
This code would look something like this:
.bottom {
/* should be moved down a distance equal to the height of
parent container minus the height of the bottom div
and the div above it */
margin-top: calc(100% - (20px + 40px));
}
Check out these neat use cases to see if this is an option you would want to consider exploring further.