Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

align div in the bottom of another div using css

Tags:

html

css

I want to align the DIV c in the bottom of the DIV b not DIV a

<div id="a">
   <div id="b">
        <div id="c">
              Div c
        </div>
   </div>
</div>
like image 908
Adham Avatar asked Jan 20 '12 01:01

Adham


2 Answers

This should work:

#b {
  position: relative;
}

#c {
  position: absolute;
  bottom: 0px;
}

The trick is position: relative; on the parent element. Without that, #c will float away to the bottom of the page.

like image 121
Blender Avatar answered Oct 10 '22 04:10

Blender


It will take div#c out of the flow of the document. It may not be perfect, but you can do something like the following:

#b {
  position: relative;
}

#c {
  position: absolute;
  bottom: 0;
}
like image 34
Max Spencer Avatar answered Oct 10 '22 05:10

Max Spencer