0

您可以在http://jsfiddle.net/ryamx/2/找到示例代码

#c {
    width:110px;
    height:57px;
    border:1px solid blue;
    margin-top:250px;
    clear:right;

}

我的目的是通过更改边距顶部的值来移动框 c。它具有明确的属性,然后它不起作用。为什么?

简单地说,如何“明确”影响元素行为

4

2 回答 2

1

尝试clear:both;

<div id="b"> b</div>
<div style="width:100%;clear:both;"></div>
<div id="c">c </div>

提琴手

于 2012-11-20T08:48:25.423 回答
0

Actually its margin-collapsing basically see the attached image

enter image description here

so we can remove that margin-collapsing through float Give the float:left; to your id #C

CSS

#c {
    width:110px;
    height:57px;
    border:1px solid blue;
    margin-top:250px;
    clear:both;
    float:left;

}

DEMO

Now see the updated image its taking margin after #b

enter image description here

于 2012-11-20T09:00:38.880 回答