CSS 悬停图像链接在 Internet Explorer 中不起作用
请参考http://solarisdutamas.com/fb/KonzeptGarden/sample.php,将鼠标移至“Pebbles Wash”并单击图像。它在 Chrome 和 Firefox 中工作正常,但该链接在 IE 中不起作用。 这是我的代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Konzept Garden</title>
<style type="text/css">
* {margin: 0; padding: 0;}
#main {
width: 520px;
height: 228px;
background-image: url(stone.jpg);
background-repeat: no-repeat;
position: relative;
margin: 0 auto;}
#main ul li {
list-style: none;
display: inline;}
#main ul li:hover {
visibility: visible;}
#main ul li a {
position: absolute;
z-index: 1;}
#main ul li a:hover {
z-index: 100;}
#main ul li img {
position: absolute;
top: 300px;
right: 999em;}
#submain1 .butt1 a {
left: 8px;
top: 80px;
width: 90px;
height: 32px;}
#main ul .butt1:hover img {
left: 8px;
top: 80px;}
</style>
</head>
<body style="margin: 0px; width: 520px;">
<div id="main">
<ul id="submain1">
<li class="butt1"><a href="http://konzeptstone.com/p_pebbles.html" target="_blank"></a><img src="p1.png"></li>
</ul>
</body>
</html>
有谁知道为什么这在 IE 中不起作用?
Please refer http://solarisdutamas.com/fb/KonzeptGarden/sample.php, mouse over to "Pebbles Wash" and click the image. It working fine in Chrome and Firefox, but the link not working in IE.
Here's my code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Konzept Garden</title>
<style type="text/css">
* {margin: 0; padding: 0;}
#main {
width: 520px;
height: 228px;
background-image: url(stone.jpg);
background-repeat: no-repeat;
position: relative;
margin: 0 auto;}
#main ul li {
list-style: none;
display: inline;}
#main ul li:hover {
visibility: visible;}
#main ul li a {
position: absolute;
z-index: 1;}
#main ul li a:hover {
z-index: 100;}
#main ul li img {
position: absolute;
top: 300px;
right: 999em;}
#submain1 .butt1 a {
left: 8px;
top: 80px;
width: 90px;
height: 32px;}
#main ul .butt1:hover img {
left: 8px;
top: 80px;}
</style>
</head>
<body style="margin: 0px; width: 520px;">
<div id="main">
<ul id="submain1">
<li class="butt1"><a href="http://konzeptstone.com/p_pebbles.html" target="_blank"></a><img src="p1.png"></li>
</ul>
</body>
</html>
Does anyone have any idea why this doesn't work in IE?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用的是早期版本的 IE,它会出现
:hover
问题。http://reference.sitepoint.com/css/pseudoclass-hover
If you are using earlier versions of IE, it has issues with
:hover
.http://reference.sitepoint.com/css/pseudoclass-hover
我知道这有点矫枉过正,但这将确保它即使在 IE 6 上也能工作:
then:
。
I know this is an overkill but this will ensure it works even on I.E. 6:
then:
.
一种选择是使用 jQuery(如果已安装)。就像 Jason 所说,:hover 在 IE6 及更低版本中不起作用,除了锚点之外,其他任何东西都不起作用。
假设您可以使用 jQuery,解决方案是:
使用 jQuery 的另一个选项是在 Hover 上动态添加一个类。
然后CSS将是:
One option is to use jQuery if you have it installed. Like Jason said, :hover doesn't work in IE6 and below, for anything OTHER than anchors.
Assuming you can use jQuery, the solution would be:
Another option using jQuery would be adding a class dynamically on Hover.
And then the CSS would be: