我有一个
元素,里面嵌套了另一个
元素。我使用jQuery在鼠标悬停在父
元素上时显示/隐藏子
元素(父
元素横跨页面底部,宽度:100%,高度为100像素)。 我已经使用Firebug和IE开发者工具确认了父
元素在页面上存在。
在Chrome和Firefox中,我可以悬停在空的父
元素上,一切正常。但是在IE中,我必须在
内放置一些文本才能悬停。如果只有空的
元素,则悬停事件不会触发。
有没有可行的解决办法?
--更新
尝试了你们所有的建议,但还没有找到解决方法。
<div id="toolBar">
<div>
<button id="btnPin" title="Click to pin toolbar" type="button">
<img id="pin" src="../../images/icons/unpin.png" alt="Pin" /></button>
<img src="../../images/icons/search.png" border="0" alt="Search" />
</div>
</div>
上述HTML被包含在一个主页面div容器中。子div使用jQuery进行隐藏,并带有一些鼠标悬停事件。父div(toolBar)始终显示在页面上。当在toolBar上发生悬停时,子div将显示。
以下是jQuery代码:
$('#toolBar').hover(ToolBar_OnHover, ToolBar_OnBlur);
function ToolBar_OnHover() {
$(this).children().fadeIn('fast');
$(this).animate({ height: "100px" }, "fast");
}
function ToolBar_OnBlur() {
$(this).children().fadeOut('fast');
$(this).animate({ height: "50px" }, "fast");
}
最后这里是一点CSS代码
#toolBar { width: 100%; height: 100px; text-align:center; vertical-align:middle; position: absolute; bottom: 0; background-color: Transparent; }
#toolBar div { padding: 5px 5px 0px 5px; width:75%; height: 95px; background: transparent url('/images/toolbar-background.png') repeat-x; margin-right: auto; margin-left: auto; }