<div style="position:relative;width:300px;height:200px;background:#3e8f9d;">
<div style="float:right;margin:10px 10px 0;height:170px;
[color=red]width:280px;[/color]background:green;">
这个奇怪的层。
</div>
<p style="position:absolute;bottom:0;right:0;
width:50px;height:30px;background:#000;color:#fff">字呢?</p>
</div>
问题的关键是标红的宽度,设置小一些,使width+marginLeft+marginRight小于父元素内部宽度, p就回来了。
Mark吧....
<div style="float:right;margin:10px 10px 0;height:170px;
[color=red]width:280px;[/color]background:green;">
这个奇怪的层。
</div>
<p style="position:absolute;bottom:0;right:0;
width:50px;height:30px;background:#000;color:#fff">字呢?</p>
</div>
问题的关键是标红的宽度,设置小一些,使width+marginLeft+marginRight小于父元素内部宽度, p就回来了。
Mark吧....
本文探讨了如何通过调整CSS属性解决特定的网页布局问题,特别是当子元素的宽度加上左右外边距超过父元素内部宽度时,如何让浮动元素回归正常位置。
3万+

被折叠的 条评论
为什么被折叠?



