1. Add content inside the parent element, and add it before the child element block, and add the content after it is invalid.
Content can be text, pictures or even spaces, the source code directly by the space is invalid, you can use the placeholder
2. Let the child element or parent element float Float:left.
Disadvantage: In cases where the element cannot be used in a float
3. To add a border to the top of the parent element, you can set the border as transparent: border-top:1px solid transparent.
Disadvantage: Although it is transparent, but also more than 1px of the occupying position, the general accuracy requirements are not high, 1px can be ignored.
4, let the child element or the parent element absolute position: Position:absolute.
Disadvantage: In cases where an element cannot be absolutely positioned
5, let the parent element Overflow:hidden.
Cons: Elements cannot be used in overflow:hidden cases.
To summarize, it is relatively perfect to add placeholders and Overflow:hidden.
Solving the problem of child element margin changing with the parent element location