简单的外边距折叠问题

来源:互联网 发布:js select foreach 编辑:程序博客网 时间:2024/05/16 11:04

1) 参加折叠的margin都是正值:取其中 margin 较大的值为最终 margin 值。

<div style="height:50px; margin-bottom:50px; width:50px; background-color: red;">A</div><div style="height:50px; margin-top:100px; width:50px; background-color: green;">B</div>

2). 参与折叠的 margin 都是负值:取的是其中绝对值较大的,然后,从 0 位置,负向位移。

<div style="height:100px; margin-bottom:-75px; width:100px; background-color: red;">A</div><div style="height:100px; margin-top:-50px; margin-left:50px; width:100px; background-color: green;">B</div>

3). 参与折叠的 margin 中有正值,有负值:先取出负 margin 中绝对值中最大的,然后,和正 margin 值中最大的 margin 相加。

<div style="height:50px; margin-bottom:-50px; width:50px; background-color: red;">A</div><div style="height:50px; margin-top:100px; width:50px; background-color: green;">B</div>

友链:
http://www.cr173.com/html/17041_1.html

0 0
原创粉丝点击