I have three nested DIV elements like this:
<div id="outer">
<div id="innerA">
<div id="innerB">
This<br/>is<br/>a<br/>multiline<br/>testcase.<br/>
This<br/>is<br/>a<br/>multiline<br/>testcase.<br/>
</div>
</div>
</div>
#innerA
has a height of 100%
which makes it as big as #outer
. #innerB
's height is left to be auto
so it gets as high as its contents. Now when i set #innerB
to have margin-top: 10px
for example i would expect that #innerB
will get a margin in relation to #innerA
. What happens instead is that #innerA
gets this margin in relation to #outer
.
How is this possible? It seems like this has nothing to do with box-sizing
at least its not fixable this way.
Here's the CSS:
#outer {
width: 500px;
height: 300px;
background: yellow;
overflow: auto;
}
#innerA {
width: 100%;
height: 100%;
background: green;
}
#innerB {
margin-top: 10px;
background: blue;
}
and the fiddle:
(Here i would expect that the green DIV fits the yellow one, and that there are 10px of the green one visible above the blue DIV).