IE6 CSS 菜单悬停问题
这个基本菜单在所有现代浏览器中都能完美工作,但在 IE6 中不起作用。
这是JSDOit 示例。
还有我的 HTML/CSS 代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>CSS Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
* {margin:0;padding:0}
/* Mega Menu */
#mega {
list-style:none;
}
#mega li {
float:left;
position:relative;
}
#mega li:hover {
border-bottom:0;
margin-top:-7px;
z-index:1;
padding:7px 0 1px;
cursor:pointer
}
#mega a:hover{
cursor:pointer
}
#mega a {
color:#000;
outline:0;
text-decoration:none;
display:block;
line-height:2em;
}
#mega div {
position:absolute;
left:-999em;
margin-top:58px;
margin-left:1px;
width:350px;
border-top:0;
font-weight:400;
text-align:left;
background:#00B8F1;
padding:0 10px 10px;
}
#mega li:hover div {
left:-1px;
top:auto;
}
#mega li.dif:hover div {
left:-221px;
}
#mega div p {
float:left;
width:106px;
padding-left:10px;
position:relative;
}
#mega div p a {
text-decoration:underline;
float:left;
clear:left;
width:100%;
line-height:1.4;
}
#mega div a:hover,#mega div a:focus,#mega div a:active {
text-decoration:none;
}
#mega div .s1,#mega div .s2,#mega div .s3 {
position:absolute;
width:100%;
height:100%;
}
#mega div .s1 {
background:url(images/rightcorner.png) 100% 0 no-repeat;
top:1px;
right:-9px;
}
#mega div .s2 {
background:url(images/leftcorner.png) 0 100% no-repeat;
bottom:-9px;
left:1px;
}
#mega div .s3 {
background:url(images/shadow.png) 100% 100%;
top:9px;
right:-9px;
}
#mega li:hover .s4 {
background:url(images/li-shadow.png) 100% 0 repeat-y;
position:absolute;
top:0;
right:-9px;
height:100%;
padding:0 8px 0 0;
}
* html #mega li:hover .s4 {
background:none;
}
#mega li:hover .dif-s4 {
padding-bottom:9px;
}
ul#mega li .sub {
top:58px;
left:0;
position:absolute;
float:left;
width:440px!important;
display:none;
padding:20px;
}
li#di div {
background-position:100px 0;
}
#mega li a#delivery-info {
width:102px;
height:59px;
position:relative;
}
#mega li a#delivery-info span {
position:absolute;
width:100%;
height:100%;
}
#mega li:hover a#delivery-info span {
position:absolute;
width:100%;
height:100%;
}
ul#topnav,ul#mega {
float:left;
width:100%;
list-style:none;
font-size:1.1em;
}
ul#topnav li,ul#mega li {
float:left;
position:relative;
z-index:1;
margin:0;
padding:0;
}
ul#topnav li a,ul#mega li a {
float:left;
line-height:1.6em;
}
ul#topnav li:hover a,ul#topnav li a:hover,ul#mega li:hover a,ul#mega li a:hover {
background-position:left bottom;
}
ul#topnav li .row,ul#mega li .row {
clear:both;
float:left;
width:100%;
margin-bottom:10px;
}
ul#topnav li .sub ul,ul#mega li .sub ul {
list-style:none;
width:150px;
float:left;
margin:0;
padding:0;
}
ul#topnav .sub ul li,ul#mega .sub ul li {
width:100%;
color:#fff;
}
</style>
</head>
<body>
<div id="bar" style="height:60px"> </div>
<div id="container">
<div id="middle">
<div id="nav">
<ul id="mega">
<li id="di"><a href="/" id="delivery-info" class="delivery-info" title="Delivery Info"><span></span>Delivery Info</a>
<b class="s4"></b>
<div> <b class="s1"></b><b class="s2"></b><b class="s3"></b><br /><br />
<p><a href="#">Lots of links go here</a></p>
<p><a href="#">Lots of links go here</a></p>
<p><a href="#">Lots of links go here</a></p>
<p><a href="#">Lots of links go here</a></p>
<p><a href="#">Lots of links go here</a></p>
</div>
</li>
</ul>
</div>
</div>
</div>
</body>
</html>
有人能给我指出正确的方向吗?
我确信这可能是非常简单的事情,但我无法理解它。
This basic menu works perfectly in all modern browsers but is not playing ball in IE6.
Here is the JSDOit example.
And my HTML/CSS code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>CSS Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
* {margin:0;padding:0}
/* Mega Menu */
#mega {
list-style:none;
}
#mega li {
float:left;
position:relative;
}
#mega li:hover {
border-bottom:0;
margin-top:-7px;
z-index:1;
padding:7px 0 1px;
cursor:pointer
}
#mega a:hover{
cursor:pointer
}
#mega a {
color:#000;
outline:0;
text-decoration:none;
display:block;
line-height:2em;
}
#mega div {
position:absolute;
left:-999em;
margin-top:58px;
margin-left:1px;
width:350px;
border-top:0;
font-weight:400;
text-align:left;
background:#00B8F1;
padding:0 10px 10px;
}
#mega li:hover div {
left:-1px;
top:auto;
}
#mega li.dif:hover div {
left:-221px;
}
#mega div p {
float:left;
width:106px;
padding-left:10px;
position:relative;
}
#mega div p a {
text-decoration:underline;
float:left;
clear:left;
width:100%;
line-height:1.4;
}
#mega div a:hover,#mega div a:focus,#mega div a:active {
text-decoration:none;
}
#mega div .s1,#mega div .s2,#mega div .s3 {
position:absolute;
width:100%;
height:100%;
}
#mega div .s1 {
background:url(images/rightcorner.png) 100% 0 no-repeat;
top:1px;
right:-9px;
}
#mega div .s2 {
background:url(images/leftcorner.png) 0 100% no-repeat;
bottom:-9px;
left:1px;
}
#mega div .s3 {
background:url(images/shadow.png) 100% 100%;
top:9px;
right:-9px;
}
#mega li:hover .s4 {
background:url(images/li-shadow.png) 100% 0 repeat-y;
position:absolute;
top:0;
right:-9px;
height:100%;
padding:0 8px 0 0;
}
* html #mega li:hover .s4 {
background:none;
}
#mega li:hover .dif-s4 {
padding-bottom:9px;
}
ul#mega li .sub {
top:58px;
left:0;
position:absolute;
float:left;
width:440px!important;
display:none;
padding:20px;
}
li#di div {
background-position:100px 0;
}
#mega li a#delivery-info {
width:102px;
height:59px;
position:relative;
}
#mega li a#delivery-info span {
position:absolute;
width:100%;
height:100%;
}
#mega li:hover a#delivery-info span {
position:absolute;
width:100%;
height:100%;
}
ul#topnav,ul#mega {
float:left;
width:100%;
list-style:none;
font-size:1.1em;
}
ul#topnav li,ul#mega li {
float:left;
position:relative;
z-index:1;
margin:0;
padding:0;
}
ul#topnav li a,ul#mega li a {
float:left;
line-height:1.6em;
}
ul#topnav li:hover a,ul#topnav li a:hover,ul#mega li:hover a,ul#mega li a:hover {
background-position:left bottom;
}
ul#topnav li .row,ul#mega li .row {
clear:both;
float:left;
width:100%;
margin-bottom:10px;
}
ul#topnav li .sub ul,ul#mega li .sub ul {
list-style:none;
width:150px;
float:left;
margin:0;
padding:0;
}
ul#topnav .sub ul li,ul#mega .sub ul li {
width:100%;
color:#fff;
}
</style>
</head>
<body>
<div id="bar" style="height:60px"> </div>
<div id="container">
<div id="middle">
<div id="nav">
<ul id="mega">
<li id="di"><a href="/" id="delivery-info" class="delivery-info" title="Delivery Info"><span></span>Delivery Info</a>
<b class="s4"></b>
<div> <b class="s1"></b><b class="s2"></b><b class="s3"></b><br /><br />
<p><a href="#">Lots of links go here</a></p>
<p><a href="#">Lots of links go here</a></p>
<p><a href="#">Lots of links go here</a></p>
<p><a href="#">Lots of links go here</a></p>
<p><a href="#">Lots of links go here</a></p>
</div>
</li>
</ul>
</div>
</div>
</div>
</body>
</html>
Can someone point me in the right direction?
I'm sure it's probably something quite straightforward but I can't get my head around it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我发现 这是一个简单的 JQuery 解决方法。
HTML...
只需将“hoverable”类添加到您想要悬停的所有标签即可。
CSS...
JQuery...
I find this an easy JQuery workaround.
HTML...
Just add the class "hoverable" to all of the tags you want to be hovered over.
CSS...
JQuery...
这里有一个 jquery 修复
http://www.danvega.org/blog/2008/1 /1/CSS-hover-selector
我们必须使用类似的修复来显示透明 png。
(关闭了 javascript 的 IE6 无论怎么看都不会好看。)
There is a jquery fix here
http://www.danvega.org/blog/2008/1/1/CSS-hover-selector
We have to use a similar fix to display transparent pngs.
(IE6 with javascript off just isn't going to look pretty any way you look at it.)
问题 ie6 悬停功能不起作用“li:hover”,该悬停功能仅适用于“a”标签
,因此我们使用 jQuery“li”悬停功能,它将支持所有浏览器
请检查此演示
http://jsfiddle.net/nPdNd/29/
如果您有任何疑问,请在此处回复
Problem ie6 hover function doesnt work "li:hover" which hover function work only on "a" tag
so we are using jQuery "li" hover function , which will support all browsers
Please check this demo
http://jsfiddle.net/nPdNd/29/
If you have any doubt just reply here