I have the following code:
<div>
<div onmouseover="this.style.color='red'"
onmouseout="this.style.color='blue'"
style="float:left">
a
<br/>
b
<br/>
c
</div>
<div onmouseover="this.style.color='red'"
onmouseout="this.style.color='blue'"
style="position:relative;">
Testing, one two three...
</div>
</div>
第一个 div 使第二个 div 中的文本向右推,但不是第二个 div 本身,所以第一个内部 div 中的 a 将被第二个内部 div 中的 T 盖住,并且悬停在 a 上将不会触发 onmouseover。
这只是一个相当简单的例子,但我如何获得这种布局,保留第二个 div 的 position:relative,而不为其添加任何 margin,因为第一个 div 可能显示也可能不显示?第二个 div 将覆盖第一个 div 似乎很奇怪。
a
的onmouseover事件无效,虽然文本不会重叠。 - yuttadhammo