Stack Man
Stack Man

Reputation: 896

Aligning multiple divs to bottom of parent div

I have multiple child divs within a parent div. Using CSS, is it possible to vertically align all of the child divs to the bottom of the parent container so that something like the following would be displayed:

enter image description here

The height of the child divs will be unknown (dynamic).

<p>Top of page</p>
<div id="container">
<div class="message">Message 4</div>
<div class="message">Message 3</div>
<div class="message">Message 2</div>
<div class="message">Message 1</div>
</div>
<p>Bottom of page</p>

style below:

#container {

    height: 500px;

    }

Problem demo.

Upvotes: 7

Views: 8192

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388316

You can use the following styles for the container

display: table-cell;
vertical-align: bottom;

Solution demo here.

Upvotes: 16

Related Questions