IE6 CSS Hover issues with menu(IE6 CSS 悬停菜单问题)
问题描述
我有一个 CSS 悬停菜单,它适用于所有浏览器,除了...惊喜 -- IE6!
I have a CSS hover menu which works in all browsers except... surprise -- IE6!
#menu_right ul li:hover ul { visibility: visible; }
这个ul
显然最初是隐藏的.当我将鼠标悬停在其父 li
上时,它应该会显示出来......但它没有.
This ul
is hidden initially, obviously. When I hover over its parent li
, it should show up... but it doesn't.
为了找出问题所在,我尝试让 ul
最初 可见 并让悬停动作采取其他方式.例如:
To try to pinpoint the problem, I've tried making the ul
initially visible and had the hover action take on something else. For example:
#menu_right ul li ul { visibility: visible; }
#menu_right ul li:hover ul { background: red; }
这没有帮助.在其他浏览器(包括 IE7+)上,当我将鼠标悬停在其父 list 元素
上时,ul
将变为红色.但不是在 IE6 中.我错过了什么?
This doesn't help. On other browsers (including IE7+), the ul
will turn red when I hover over its parent list element
. But not in IE6. What am I missing?
推荐答案
IE6 不知道 CSS :hover
伪属性,当它出现在除了链接元素之外的任何东西上时.为此,您将不得不使用 JavaScript.试试条件语句,如果你使用jQuery,可以在3(+/- 格式)行:
IE6 doesn't know the CSS :hover
pseudo-attribute, when it appears on anything than a link element. You will have to use JavaScript for this. Try conditional statements, and if you use jQuery, you can code the hover effect for IE6 in 3 (+/- formatting) lines:
<!--[if lt IE 7]>
<script type="text/javascript">
$('#menu_right ul li').hover (function () {
$(this).addClass ("hover");
}, function () {
$(this).removeClass ("hover");
});
</script>
<style type="text/css">
#menu_right ul li.hover {...}
...
</style>
<![endif]-->
马克,我在 CSS 语句中使用了点而不是冒号.
Mark, that in the CSS statements I used the dot instead of the colon.
干杯,
这篇关于IE6 CSS 悬停菜单问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:IE6 CSS 悬停菜单问题


- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01