hack :
the parent element's box contains a child element box, giving the child element box a vertical margin margin-top, the parent element box will also go down the value of margin-top, while the margins of the child element and the parent element do not happen Variety.
hytml code:
<div class="box1">
<div class="box2"></div>
</div>
css code:
.box1{height:200px;width:200px;background:gray;}
.box2{height:100px;width:100px;background:gold;margin-top:50px;}
Solution :
1. Modify the height of the parent element and increase the padding-top style simulation (padding-top: 1px; commonly used)
2. Add overflow: hidden to the parent element; the style is fine (perfect)
3. It is the parent element or child element Declare float (float: left; available)
4. Add border to parent element (border: 1px solid transparent available)
5. Declare absolute positioning for parent or child element