margin传递,子元素的上下margin会传递给父级

 1 <!doctype html>
 2 <html>
 3 <head>
 4 <meta charset="utf-8">
 5 <title>无标题文档</title>
 6 <style>
 7 #box{ background:red;}
 8 #div{width:200px;height:200px;background:blue;margin:100px;}
 9 #footer{height:50px;background:yellow;}
10 /*
11     margin传递,子元素的上下margin会传递给父级
12 */
13 </style>
14 </head>
15 <body>
16 <div id="box">
17     <div id="div"></div>
18 </div>
19 <div id="footer"></div>
20 </body>
21 </html>
原文地址:https://www.cnblogs.com/hduhdc/p/5225536.html