【发布时间】:2014-09-16 20:54:45
【问题描述】:
将鼠标悬停在可见 div 容器上后,我无法正确显示隐藏的 div 容器。
当 d1 悬停在 d2 上时会出现,但会出现某种闪烁。这是我所拥有的:
注意:我仍然希望 d1 可见,因为我想使用 d2 在 d1 上显示文本
css:
.website{
width:400px; height:400px; background: black;
}
.website .d1, .website .d2{
width:100%; height:100%; float:left;
}
.d1{
background:red;
width:100%; height:100%; float:left
}
.d2{
background:blue;
margin-top:-400px; display:none; z-index:100;
}
.d1:hover + .d2 {
display: block;
}
html:
<div class='website'>
<div class='d1'></div>
<div class='d2'></div>
</div>
【问题讨论】:
-
为什么不用 onmouseout 和 onmousein ?
-
在 JS 事件中?这个特殊任务有点矫枉过正