图像在 ie7 中消失而不是显示
我正在使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经制作了一个演示,它似乎适用于 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 thefilter: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.