问题描述
我有一个 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 悬停菜单问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)