I have been trying to solve this problem for a while, could not find solutions.
Here is my code
CSS
.parent{
width:100px;
display:table;
border:1px solid green;
}
.child{
width:50px;
background:blue;
display:table-cell;
height: inherit;
}
.child + .child{
background:red;
}
HTML
<body>
<div class="parent">
<div class="child">a <br/> b<br/> b<br/> b<br/> b<br/> b<br/> b</div>
<div class="child" style="border: 2px dashed black">
<fieldset style="height:100%;">a</fieldset>
</div>
</div>
</body>
I want the fieldset in second child div to take the height of the parent div. So, the height of the fieldset should be equal to the height of child div it is in.
How do I do that?
Height as a percentage works when the parent’s height is declared. In your case,
height: inherit;but it’s inheriting nothing from it’s parent called.parent. Settingheighton.parentfixes it. (Alternatively, you could set theheightof the child called.childto something other thaninherit.)http://jsfiddle.net/HtAJw/
HTML:
CSS: