图像在 ie7 中消失而不是显示

发布于 2024-10-30 20:54:15 字数 742 浏览 10 评论 0原文

我正在使用 CSS 悬停和不透明度,当您将鼠标悬停在一张图像上时,它会变成另一张图像,方法是将一个图像放在顶部并设置不透明度,以便它在悬停时消失并留下底部图像。代码如下:

#fade {
    overflow:hidden;
    margin:0 auto;


}
#fade img {
    position:absolute;
    left:0;
    top:0;
    right:0;
    bottom:0;
    width:100%;
    height:100%;
    -webkit-transition: opacity 1s ease-in-out;
    -moz-transition: opacity 1s ease-in-out;
    -o-transition: opacity 1s ease-in-out;
    transition: opacity 1s ease-in-out;
    }



#fade img.topfade:hover {
    opacity:0;
    -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=5)";
    filter:alpha(opacity=.5);
    -moz-opacity:0.5;
    -khtml-opacity: 0.5;

}

这在 ie8、ie9 和 firefox 中工作正常,但在 ie7 中,当第一个图像不可见时,第二个图像不存在。有人知道如何解决这个问题吗?

I'm using CSS hover and opacity to make one image change into another when you hover over it, By placing one on top and setting the opacity so that it disappears on hover and the bottom image is left. Code is as follows:

#fade {
    overflow:hidden;
    margin:0 auto;


}
#fade img {
    position:absolute;
    left:0;
    top:0;
    right:0;
    bottom:0;
    width:100%;
    height:100%;
    -webkit-transition: opacity 1s ease-in-out;
    -moz-transition: opacity 1s ease-in-out;
    -o-transition: opacity 1s ease-in-out;
    transition: opacity 1s ease-in-out;
    }



#fade img.topfade:hover {
    opacity:0;
    -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=5)";
    filter:alpha(opacity=.5);
    -moz-opacity:0.5;
    -khtml-opacity: 0.5;

}

This works fine in ie8,ie9 and firefox but in ie7 the second image is not there when the first image is made invisible. Anyone know how to fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黒涩兲箜 2024-11-06 20:54:15

我已经制作了一个演示,它似乎适用于 Chrome、Firefox 和 IE7。

它在 IE8+ 中工作,因为 -ms-filter 规则是正确的,但是 IE7 中的不透明度是 filter:alpha(opacity=xx) 规则,值应为 0 到 100 之间。您当前的值 .5 使悬停图像几乎完全不透明(而且我不确定它是否有效)。

quirksmode 对 IE 的不同不透明度 CSS 规则进行了很好的总结。

注意:在您的示例结构中,您在我添加的

  • 之前缺少

        在演示中。
  • I have made a demo which seems to work for me in Chrome, Firefox and IE7.

    It works in IE8+ as the -ms-filter rule is correct, however opacity in IE7 is the filter:alpha(opacity=xx) rule and the value should be between 0 and 100. Your current value .5 is making the hovered image almost totally opaque (and I'm not sure it's even valid).

    quirksmode has a good summary of the different opacity CSS rules for IE.

    Note: In your example structure you are missing a <ul> or <ol> before the <li> which I have added in the demo.

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文