问题:
父div在没边框的情况下,子div如果设了 margin-top, 子div的margin无效,父div有了子div的margin-top属性.假设设了边框就没问题.
例子:
1
<
div
style
=”width:400px;
height:30px; background:#CCCCCC; border:1px solid #999999″
>
2 < div style =”margin-top:5px; width:55px; height:25px; background:#003399″ ></ div >
3 </ div >
4
5 < div style =”width:333px; height:40px; background-color:#000000″ >
6 < div style =”width:33px; height:20px; margin-top:5px; background:#CCCCCC” ></ div >
7 </ div >
2 < div style =”margin-top:5px; width:55px; height:25px; background:#003399″ ></ div >
3 </ div >
4
5 < div style =”width:333px; height:40px; background-color:#000000″ >
6 < div style =”width:33px; height:20px; margin-top:5px; background:#CCCCCC” ></ div >
7 </ div >
解决方法:
给父DIV设个:overflow:hidden;