我使用 top: -50px;
将 div 重叠(div2 在 div1 之上)将其向上推。现在它在下一个 div (div3) 之前留下 50px。我怎样才能“清除”它并使 div (div3) 恰好位于我定位的 -50px 的 div (div2) 下方?
<div id="div1" style="width: 1000px; height: 90px; background: red;"></div>
<div id="div2" style="position: relative; top:-50px; width: 1000px; height: 90px; background: blue;"></div>
<!--50 wasted pixels here-->
<div id="div3" style="width: 1000px; background: green; height:90px;"></div>
最佳答案
将 margin-top: -50px
添加到您的 #div3:
<div id="div3" style="width: 1000px; background: green; height:90px; margin-top: -50px;"></div>
fiddle :http://jsfiddle.net/N7z6e/
关于css - 用Top : -px定位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13635324/