waffel’s Weblog

Juni 10, 2008

place a div element always bottom

Filed under: css,html,software — Thomas Wabner @ 11:35 am
Tags: ,

A while ago I have searched for a solution to place a <div> element inside another <div> element always bottom. There are many solutions to put the div bottom from the whole html site but rar solutions to put it in the container div bottom.

Now here comes my solution …

I have one div container (calling it simple container) with a height of 100% (this container itself is placed for example in another parent container which has a height of 400px). And I have my div which should placed bottom of the container:

<div id="container" style="height:100%; position:relative;">
  <div id="bottom_div" style="height:10%; position:absolute; bottom:0px;"/>
</div>

The trick is to give the container div a position relative and then you can use the position absolute in the bottom div element. If the container div has no position style atribute it will not work.

16 Kommentare »

  1. Thanks so much

    perfect tip

    Kommentar von Miles — Juli 17, 2008 @ 1:36 pm | Antworten

  2. thanx for this tuto, you are the men 🙂
    CSS rules men 🙂 thanx

    Kommentar von afperea — Februar 21, 2009 @ 9:41 am | Antworten

  3. I couldn’t get this working under IE 6/7. Are you sure this is the right solution? Box is always in the top left for me.

    Kommentar von widmo — März 12, 2009 @ 2:23 am | Antworten

  4. Cool mate,
    That works fine.

    Kommentar von Nico — März 25, 2009 @ 1:51 am | Antworten

  5. Thanks!!

    Kommentar von Jakob — April 17, 2009 @ 6:32 am | Antworten

  6. It does not work under IE6/7 😦

    Kommentar von Dickwan — August 31, 2009 @ 11:57 pm | Antworten

    • Hmm … strange. We are using in our projects this solution for IE6/7 and firefox 2/3 without problems.

      You can check if your div containers not inside other block elements which have a position.

      Kommentar von Thomas Wabner — September 1, 2009 @ 10:57 am | Antworten

    • Doesn’t work at all if you are using a doctype (which is required if you need valid code).

      Doctype-declarations (eg ) brick this solution.

      This solution seems to work only if Browsers render the HTML in Quirks mode. Check out IE’s Developer Tools and try to change the document mode to see what i mean.

      –> http://validator.w3.org/

      Kommentar von Herr Schnorf — Januar 31, 2012 @ 2:31 pm | Antworten

  7. Hi! I was surfing and found your blog post… nice! I love your blog. 🙂 Cheers! Sandra. R.

    Kommentar von sandrar — September 10, 2009 @ 8:52 pm | Antworten

  8. Thank you so much, it works absolutely perfect ❤

    Kommentar von ashyda — Juli 12, 2010 @ 3:58 pm | Antworten

  9. […] place a div element always bottom June 20089 comments Hinterlasse einen Kommentar LikeBe the first to like this post. […]

    Pingback von 2010 in review « waffel’s Weblog — Januar 3, 2011 @ 1:04 pm | Antworten

  10. Excellent tip it worked for me. I added right:0; to make it right align…thx for the post

    Kommentar von WeCode — Juni 22, 2011 @ 10:12 am | Antworten

  11. What if, inside parent div, you have two div’s. The top div, height is dynamic, and bottom div is also dynamic, but bottom div must stick to the bottom. even the parent div is dynamic in height.

    Illustration: Its a left side bar, which needs to have ads at the side bottom, aligned to the content at the right side.

    Any tips for that?

    Kommentar von Kelvin Castelino — August 25, 2011 @ 8:21 am | Antworten

  12. Thanks for this! it really helped me! 🙂

    Kommentar von Aj Banda — Dezember 7, 2011 @ 3:57 am | Antworten

  13. I can manage to place the element at the bottom just fine, but what I really need is 2 div elements at the bottom. This is for 2 ads on a right rail container, those always need to be at the bottom, but one above the other… makes sense? I know I could use javascript to calculate the height of the bottom div and place the other one with that info, but don’t know if there’s a pure css solution?

    Kommentar von Francisco — April 3, 2012 @ 11:53 pm | Antworten

    • Why do you not put one „container“ div at the bottom and inside this container, place your other div elements as you want?

      like

      Kommentar von Thomas Wabner — April 4, 2012 @ 1:37 pm | Antworten


RSS feed for comments on this post. TrackBack URI

Hinterlasse einen Kommentar

Bloggen auf WordPress.com.