In this question someone was having a layout problem because they had two floated divs inside a non-floated div. I suggested adding float: left
to their outer div, which does fix the problem. Someone else suggested adding overflow: hidden
, which to my surprise, also worked.
This doesn't seem at all like the purpose of of overflow: hidden
. Clearly overflow: hidden causes elements to view their children differently somehow. What I'm really trying to understand is what that difference is. Intuitively it should only make the element smaller than it would otherwise be, never bigger and I don't see why it would affect the layout hierarchy.
Can anyone explain why this would be correct/necessary behavior or if this is just a browser quirk? Is their another facet to the overflow property I'm missing? Is either solution any better than the other?
Edit: I've discovered setting overflow: auto
works too, so it doesn't seem to be the value of overflow that's important, just that it's set. I still don't understand why.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…