Bottom class helper - Align a div to the bottom of its container

Posted on May 27, 2009 by Javier Ayala

Categories: Challenges

The idea of this feature is to vertically align a div to the bottom of the parent container. This features has to be done without the use of absolute positions or overflow hiddens.

If you got and idea of to solve this challenge leave a comment.

Good luck in this challenge.

If you enjoy this post, please share it.
  • Digg
  • Reddit
  • DZone
  • del.icio.us
  • StumbleUpon
  • Technorati
  • LinkedIn
  • TwitThis
  • E-mail this story to a friend!

6 Comments »

fernando trasviña says:

this is easy

Javier Ayala says:

I think that the key of this challenge is to make a div to handle a top margin and maybe some z-index so that it doesn’t mess with other elements inside the same div.

john says:

Aligning items to the bottoms of their containers should be easy in CSS but its not. on my website http://www.checkdrugs.com there were two issues that had to be addressed: 1 Getting multiple columns to be the same height and pushing contents in one column down to the bottom.

Eventually The only maintainable way I could achieve this was with a dummy div with a top margin set to a percentage, I had a couple of classes set-up for different percentages. It’s not a great solution but its the best I have found so far.

Fernando Trasviña says:

It is so nice to recieve participation from the real developers, with elastic this can be achieved easily using the “bottom” class.

How does this class work? It is proccessed by the elastic engine helpers, this helper sets the parent element padding to the difference between the parentElement and the current element height taking padding in these elements into consideration.

So if you ask. Is this handled by javascript? The answer is yes.
Why is this not handled using “position:absolute; bottom:0px” because it is a very obtrusive technique, due to a context creation by position relative or absolute.

Aaron says:

using bottom: 0; will still let it fall to the bottom of the page past its inheritance on a parent div, as far as I can tell cant be done (with just CSS)

Maybe someone can prove me wrong…?

Arowolo says:

I have being using elasticss for about a month now, and i find it interesting and very very easy to learn.

I just worked on this topic and you can see a demo here

Leave your comment
Copyright © 2009 Elasticss.com. All rights reserved.
Made with Elastic