Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stretch child div height to fill parent that has dynamic height

Tags:

html

css

As it can be seen in the following fiddle, I have two divs, contained in a parent div that have stretched to contain the big div, my goal is to make those child divs equal in height.

http://fiddle.jshell.net/y9bM4/

like image 921
Khaled Avatar asked Jul 27 '13 16:07

Khaled


People also ask

How do I stretch a div to a full height container?

Method 2: We can make the display attribute of the child container to table-row and display attribute of parent container to table, that will take all the height available from the parent div element. To cover all the width, we can make the width of parent div to 100%.

How do you make a div fill its parent container?

The width property is used to fill a div remaining horizontal space using CSS. By setting the width to 100% it takes the whole width available of its parent. Example 1: This example use width property to fill the horizontal space. It set width to 100% to fill it completely.


1 Answers

Use display: flex to stretch your divs:

div#container {     padding:20px;     background:#F1F1F1;     display: flex; }  .content {     width:150px;     background:#ddd;     padding:10px;     margin-left: 10px; } 

JSFIDDLE

like image 186
Trong Lam Phan Avatar answered Oct 12 '22 05:10

Trong Lam Phan