使用 jquery fade 悬停在 IE 资源管理器中将 PNG 周围黑色

发布于 2025-01-05 08:09:43 字数 1238 浏览 1 评论 0原文

当我在 Internet Explorer 中使用 Fadein jquery 效果时,我搜索了一整天并尝试了一切方法来去除 PNG 周围的黑色。我一定错过了一些东西,因为我使用的所有代码都不能修复它。我的页面可以在这里访问:http://www.kaimeramedia.com/derek/Website

我找到了这段代码:

.item img {
    background: transparent;
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF)";
/* IE8 */
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF);
/* IE6 & 7 */
    zoom: 1;
}

但我无法让它与我的菜单页面一起使用( http://www.kaimeramedia.com/derek/Website/menu.php)仅在index.php模板中看起来正确。

图像在所有浏览器中都可以很好地淡入淡出,只是 IE 6+ 在图像周围添加了非常粗的黑色边框。我知道有很多网站讨论这个问题,但我没有任何运气,或者至少我输入的代码一定是错误的。

我尝试编辑 CSS 和下面的样式标签,但似乎没有任何效果:

div.fadehover {
     position: relative;
}

img.b {
     position: absolute;
     left: 0;
     top: 0;

     z-index: 10;
     opacity: 0;
     filter: alpha(opacity=0);
     background: transparent;
}

.style2 {   font-style: italic;     color: #2D6773; }
.style3 {   color: #122833 }

如果有人可以帮助我为我的网站提供可行的解决方案,我将非常感激。

I've searched all day and tried everything to remove the black around my PNGs when I use the Fadein jquery effect in internet explorer. I must be missing something because all the code I use doesn't fix it. My page can be visited here: http://www.kaimeramedia.com/derek/Website

I found this bit of code:

.item img {
    background: transparent;
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF)";
/* IE8 */
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF);
/* IE6 & 7 */
    zoom: 1;
}

but I am unable to get it to work with my menu page ( http://www.kaimeramedia.com/derek/Website/menu.php) which only looks correct in the index.php template.

The images fade on and off fine in all browsers it just that IE 6+ puts a really thick black border around it. I know there are many sites that discuss this issue, but I haven't had any luck or at least I must be inputting the code wrong.

I tried editing CSS and the style tags below but it didn't seem to have any effect:

div.fadehover {
     position: relative;
}

img.b {
     position: absolute;
     left: 0;
     top: 0;

     z-index: 10;
     opacity: 0;
     filter: alpha(opacity=0);
     background: transparent;
}

.style2 {   font-style: italic;     color: #2D6773; }
.style3 {   color: #122833 }

If someone could help me with a working solution to my site that would be really appreciated.

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

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

发布评论

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

评论(2

段念尘 2025-01-12 08:09:43

这个问题有很多解决方案:
1) 使用 PNG8 代替
2) 使用js脚本,例如Unit PNG Fix
3) 尝试将 filter: 0 添加到您的图像
4)使用ie过滤背景模拟rgba(255,255,255,0)

background: transparent;
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF)"; /* IE8 */   
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF);   /* IE6 & 7 */      
zoom: 1;

5)最后,如果不需要透明度,只需使用jpg

编辑:这是其中一张图像在png8中的样子,我不知道没有看到任何重大差异...
关于 PNG8

There are many solutions to this problem:
1) Use a PNG8 instead
2) Use a js script such as Unit PNG Fix
3) Try adding filter: 0 to your image
4) Use and ie filtered background emulating rgba(255,255,255,0)

background: transparent;
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF)"; /* IE8 */   
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF);   /* IE6 & 7 */      
zoom: 1;

5) Finally, if no transparency is needed, just use a jpg

EDIT: This is how one of the images looks in png8, I don't see any major differences...
About PNG8

眼趣 2025-01-12 08:09:43

我遇到了完全相同的问题,这是由 IE 需要的 css 过滤属性引起的。在我的动画中我删除了这个属性。

$('elem').css('filter', '');

旧的 IE 根本无法执行。你可以用 JavaScript 来“破解”许多 IE 的缺陷,但只会导致这些浏览器的运行速度更加缓慢。

最好的解决方案是优雅降级和渐进增强(更多内容请参见 http ://dev.opera.com/articles/view/graceful-degradation-progressive-enhancement/)。不要让IE做它不能做或不能做好的事情。我知道客户很难理解这一点,但我尝试成为魔术师的日子已经结束了。

I've had this exact same problem which is caused by the css filter-property IE requires. In my animation I remove this attribute.

$('elem').css('filter', '');

The old IEs simply cannot perform. You can "outhack" many of IEs flaws with javascript only causing these browsers to slow down even more.

The best solution is graceful degradation and and progressive enhancement (more of that on http://dev.opera.com/articles/view/graceful-degradation-progressive-enhancement/). Don't make IE do things it can't or cannot do well. I know clients have a hard time understanding this but my days of trying to be a magician are over.

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