Double margin
Record a little bit, because often forget
float + margin, the actual margin will change to double the set value.
The workaround is to set the element to Display:inline
It is best to understand IE's haslayout problem
margin overlap in vertical direction
Previously, it was known that adjacent two block elements overlap in the vertical direction of margin.
But the overlap between the parent element and the first child element is not considered
The code is as follows:
<Divclass= "Wrap"> <Divclass= "One">Margin 20px</Div> <Divclass= "both">Margin 20px</Div> </Div> <Divclass= "WRAP2">Margin-top 50px test Distance to wrap</Div>
. Wrap{margin:0;Background-color:lightcoral;. One {margin:20px;Background-color:LightBlue; }. the{margin:20px;Background-color:LightGreen; }}. WRAP2{Margin-top:50px;Background-color:Lightgoldenrodyellow;Height:200px; }
If wrap contains no padding or border set, the margins of the wrap block overlap with the child elements.
The effect of adding a border is as follows.
The overlap problem that margin has encountered