Css 答:将鼠标悬停在img上方,IE&;下的显示块无法正常工作;歌剧院

Css 答:将鼠标悬停在img上方,IE&;下的显示块无法正常工作;歌剧院,css,internet-explorer,hover,image,Css,Internet Explorer,Hover,Image,是否有人在位置为绝对位置且在上方的a:hover出现问题 不在IE下工作这不是 函数a(){ document.body.innerHTML+='#t a{background:pink;}',返回false; } 函数怪癖(){ 预警(document.compatMode),返回false; } 这是一个非常古怪的错误。现在,如果你真的必须按照你的方式组织你的html,那么IE需要在a标记中放置以下内容,以使其与图像注册 <!DOCTYPE html PUBLIC "-//W3C//

是否有人在位置为绝对位置且在上方的a:hover出现问题 不在IE下工作这不是


函数a(){ document.body.innerHTML+='#t a{background:pink;}',返回false; } 函数怪癖(){ 预警(document.compatMode),返回false; }
这是一个非常古怪的错误。现在,如果你真的必须按照你的方式组织你的html,那么IE需要在
a
标记中放置以下内容,以使其与图像注册

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Test</title>
<style type="text/css">
div {
    border: 1px solid black;
    position: relative;
    height: 200px;
    width: 500px;
}
a.next {
    right: 0;
}
a.prev {
    left:0;
}
.withbackground {
    background: yellow;
}
.nobackground {
    background: transparent;
}
a.link {
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
    border:0;
}
a.link:hover, a.link:focus {
    background: url(/img/comment.gif) repeat !important;
}
</style>
</head>
<body>
    <div id="t">
        <a class="link nobackground" href="#">&lt;a&gt; without background</a>
        <img src="/img/DSC_00641.jpg" height="200" width="500" alt="Dummy img" />
    </div>
    <p>Doesnt work under IE? <a href="#false" onclick="return a();">Add background</a> | This is not <a href="#" onclick="quirks()">quirks mode</a> <a href="http://www.satzansatz.de/cssd/quirksmode.html">#</a></p>
    <hr />
    <div>
        <a class="link withbackground" href="#">&lt;a&gt; with background</a>
        <img src="/img/DSC_00641.jpg" height="200" width="500" alt="Dummy img" />
    </div>
    <div> <a class="link nobackground" href="#">&lt;a&gt; without background, without img</a> </div>
    <script type="text/javascript">
        function a() {
            document.body.innerHTML+='<style>#t a {background: pink;}</style>';return false;
        }
        function quirks() {
            alert(document.compatMode); return false;
        }
    </script>
</body>
</html>
确保
a
不是
position:absolute
(IE7没有使用它),然后将图像设置为:

<a><img /></a>

我希望这些能引导你朝着解决问题的方向前进。

斯科特,谢谢你的回答。这只是问题的一个例子

当然,我真正的代码比这还要大:
-2个标签来导航上一个/下一个(因此我无法放置
)-单击Exif info并将鼠标移动到image/new“layer”

我也遇到了这个问题。我通过向空的绝对定位容器添加一个空白的.gif背景图像来“修复”它。
<a><img /></a>
img {position: absolute; z-index: -1}