我是新学习 HTML,现在我有一些代码,例如
<div id="container" style="height:300px;width:500px;font-size:0">
<div id="leftBox" style="display: inline-block; background: pink; width: 50%; height: 100%;">
<div id="wrapper" style="height:10%;">
<div style="display: inline-block; background: red; width: 50%; height: 100%;"></div>
<div style="display: inline-block; background: blue; width: 50%; height: 100%;"></div>
</div>
</div>
<div id="rightBox" style="display: inline-block; background: green; width: 50%; height: 100%;"></div>
</div>
(我把它贴在http://jsfiddle.net/Simon_Chan/Z3WyA/上)
可以看到leftBox
有一个很大的offsetTop,但是如果没有wrapper
或 wrapper
的高度为100% ,或者没有rightBox
或没有元素wrapper
,在所有这些条件下leftBox
都没有offsetTop。
为什么这样做?以及如何删除它?
谢谢!