我有一个 div,里面有一个子 div。每当鼠标悬停在父 div 上时,我使用 jQuery 显示/隐藏子 div(父 div 跨越页面的整个底部。宽度:100% 和高度 100px)。我已经使用了 firebug 和 ie 开发者工具栏来确认父 div 在页面上。
我可以将鼠标悬停在 Chrome 和 FireFox 中的空父 div 上,一切正常。IE 要求我在里面有某种文本可以悬停在上面。div 悬停事件不会仅以空 div 触发。
这个问题的所有可能的解决方法?
- 更新
尝试了您的所有建议,但没有任何效果。
<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 上发生悬停时,将显示子 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; }