First, see the following example:
(1) HTML part content
<body> <ul> <li> Revenge moments </li> <li class= "Widthborder" > Moreau asked Bourg to bring the child Danny to the shrine to avoid the Devil's capture of his soul, in return for the curse he would banish Bourg. </li> </ul> <ul> <li> Source code </li> <li class= "Widthborder" > Cole suddenly woke up on a high-speed train, and his side sat with a woman who was strangers talking to herself. </li> </ul></body> (2) CSS content ul{ backgroud: #ddd; margin:15px; padding:5px;} li{ Color:black; Background: #aaa; margin:20px; padding:10px; List-style:none;} li.widthborder{ border-style:dashed; border-width:5px; Border-color:black; margin-top:20px;}
(3) distance calculated:
(4) Explanation:
in the standard flow: I, the horizontal margin between the elements of the line is cumulative II, the vertical margin between block-level elements is collapsed III, nested box if the father does not specify the size, The default setting is that the parent box is exactly the size of the child box, and if the parent box is sized and the parent box is smaller than the child box, IE6 automatically resizes the parent box to fit the inclusion relationship, while Firefox does not automatically adjust.