在CSS开始中,发现即使内部元素设置了margin也不能撑开div容器的高度。
这不是浏览器的bug,在IE、FF和Opera,有这样的现象。
看下面的代码,即使设置了p的margin四周均为20px,依然不能让div高度发生变化,背景色只有p所在区域可见。

看下面几个解决办法:
一、所有浏览器有效 <div style="background:#eee;border:1px solid #eee;">
但不能无缘无故的加边框……
二、所有浏览器有效 <div style="background:#eee;float:left;width:100%/*维持原来宽度*/">
给元素加上浮动属性。
三、IE下有效 <div style="background:#eee;zoom:1;">
用zoom属性来纠正。
四、FF和Opera下有效 <div style="background:#eee;overflow:hidden;">
用溢出隐藏来纠正。
五、变变思考,将p的margin转换为div的padding。
有点怪怪的。
通常使用第二和第五种方法。
二、给元素加上浮动属性。

五、变换思考,将p的margin转换为div的padding。
