Here is the HTML:
<div id="outer">
<div id="inner"></div>
Test
</div>
And here is the CSS:
#inner {
float: left;
height: 100%;
}
Upon inspection with the Chrome developer tools, the inner div is getting a height of 0px.
How can I force it to be 100% of the height of the parent div?
For
#outerheight to be based on its content, and have#innerbase its height on that, make both elements absolutely positioned.More details can be found in the spec for the css height property, but essentially,
#innermust ignore#outerheight if#outer‘s height isauto, unless#outeris positioned absolutely. Then#innerheight will be 0, unless#inneritself is positioned absolutely.However… By positioning
#innerabsolutely, afloatsetting will be ignored, so you will need to choose a width for#innerexplicitly, and add padding in#outerto fake the text wrapping I suspect you want. For example, below, the padding of#outeris the width of#inner+3. Conveniently (as the whole point was to get#innerheight to 100%) there’s no need to wrap text beneath#inner, so this will look just like#inneris floated.I deleted my previous answer, as it was based on too many wrong assumptions about your goal.