Let's say I have this small HTML snippet:
<div id="outer">
<div id="inner">
<div id="inner2">foo bar</div>
</div>
</div>
I also have these styles defined:
#outer {
height:100px;
overflow:auto;
background-color:#EEE;
}
#inner {
height:100px;
background-color:#AAA;
}
#inner2 {
margin-top:5px;
}
With this setup, scroll bars appears with the outer
div:
Why does the nested inner div causes this scrollbar to appears?
I can remove the scrollbar by removing the margin-top
rule, but this would cause side effects.
Here is a jsfiddle that reproduces the issue: http://jsfiddle.net/stevebeauge/PTA85/
[edit]: my actual issue is solved by replacing margin-top
by padding-top
, but I'm looking for an explanation, not only the solution.