Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to place div at the bottom of another div?

Tags:

html

css

How do I place the adInfoBox1 at the bottom of the container?

Take a look at this: http://jsfiddle.net/snowman/hxXJh/

Please note that the container will not have a fixed height.

like image 779
Banshee Avatar asked Mar 17 '11 19:03

Banshee


3 Answers

You can use position: absolute.

.container
{
    height: 400px;
    position: relative;
}

.adInfoBox1 {
  padding: 5px 5px 5px 10px;
  position: absolute;
  bottom: 0px;
  width: 457px;
  background-color: green;
}

.adRegularList .categoryList {
  bottom: 0;
  height: 16px;
  position: absolute;
}

See a working example here: http://jsfiddle.net/hxXJh/5/

like image 76
Intelekshual Avatar answered Oct 31 '22 17:10

Intelekshual


I'd suggest:

.adInfoBox1 {
    padding: 5px 5px 5px 10px;
    position: absolute;
    bottom: 0; /* attaches the element to the bottom */
    left: 0; /* attaches the element to the left-side */
    right: 0; /* attaches the element to the right-side */
    background-color : green;
}

The above will give the .adInfoBox 100% width, implicitly. This can be adjusted by removing, or amending, the right or left declarations. I removed the float because using position: absolute; will take the element out of the document flow anyway.

JS Fiddle demo.

like image 6
David Thomas Avatar answered Oct 31 '22 18:10

David Thomas


Simple tricky solution. Div2 will be at the bottom of containerDiv.

<div id="containerDiv">
   <div id="div1" style="heigth:90%;"></div>
   <div id="div2">Content here...</div>
</div> 
like image 1
yurin Avatar answered Oct 31 '22 19:10

yurin