简体   繁体   English

IE8中的透明PNG周围的黑色边框

[英]Black border Around Transparent PNG in IE8

I'm experiencing some problemes with a black small border around transparent PNG files..in a jquery slider in IE8.. It works fine in all browsers (including IE6 & 7) but not in IE8. 我遇到一些问题,在透明的PNG文件周围有一个黑色小边框..在IE8中的一个jquery滑块..它适用于所有浏览器(包括IE6和7)但在IE8中没有。

you can see it here: http://www.socialogika.com/tabs/goliath/collection/ 你可以在这里看到: http//www.socialogika.com/tabs/goliath/collection/

I allready tried several fixes found here on stackoveflow, but none of them seems to be the solution (yet)...turning to PNG-8 from 24 fixed the problem voor Ie6 & 7, but still havind problems in 8 我已经尝试过在stackoveflow上找到的几个修复程序,但它们似乎都不是解决方案(还)...转向PNG-8从24修复了Ie6和7的问题,但仍然存在问题8

Can someone point me to a working solution? 有人能指出我的工作解决方案吗?

Let me know if this helps: http://channel9.msdn.com/forums/TechOff/257324-IE7-alpha-transparent-PNG--opacity/ 如果有帮助请告诉我: http//channel9.msdn.com/forums/TechOff/257324-IE7-alpha-transparent-PNG--opacity/

I have done a lot of research into the IE7 png with opacity issue and have used two workaround which cover most, but sadly not all scenarios. 我已经对IE7 png进行了大量关于不透明度问题的研究,并且使用了两种解决方法,其中涵盖了大多数,但遗憾的是并非所有场景。

The first one has already been mentioned in this thread which is to have different image files for the different opacities needed. 第一个已经在这个线程中提到过,它将为所需的不同不透明度提供不同的图像文件。 This method works for well for mouseover and mouseout effects when you just want to show state, but is sadly useless when you want to animate the opacity. 当您只想显示状态时,此方法适用于鼠标悬停和鼠标悬停效果,但是当您想要为不透明度设置动画时,这种方法可能无用。

The second method will work most of the time but it depends on your pagelayout and design. 第二种方法大部分时间都可以工作,但这取决于你的pagelayout和设计。 To fake the opacity animation of a div you can position a dummy second div over the real div you want to show an opacity change on. 要伪造div的不透明度动画,您可以在想要显示不透明度变化的真实div上放置一个虚拟的第二个div。 The second div should be absolutely positioned and take on the width and height of the background div. 第二个div应该绝对定位并采用背景div的宽度和高度。 Depending on your page design you then give it a background colour (whatever best suits the real background image png) and you animate the opacity on that div to fade in or out depending on the effect you are looking for. 根据您的页面设计,您可以给它一个背景颜色(最适合真实背景图像png),然后根据您要查找的效果设置该div上的不透明度以淡入或淡出。

Because you will be using javascript for the opacity animation anyway, it is simple to create and insert the new div when the effect is needed and remove it once you are done. 因为无论如何你将使用javascript作为不透明度动画,所以在需要效果时创建并插入新div很简单,一旦完成就将其删除。 This allows the actual divs content to still be copy and pasted or right clicked by visitors to the site. 这样,实际的div内容仍然可以被网站访问者复制,粘贴或右键单击。

Also, perhaps try confirming my hunch that it's the opacity that's causing the black border to show: disable all fade effects and let me know if the images render correctly. 此外,也许尝试确认我的预感,这是导致黑色边框显示的不透明度:禁用所有淡入淡出效果,让我知道图像是否正确渲染。

Well... try using 好吧......尝试使用

.fadeTo() .fadeTo()

DEMO DEMO

In any case you can use this little fix: 在任何情况下,您都可以使用这个小修复:

$('#mages img').css({background: '#EDE7DE'});

Or create an if statement for IE where you just add an .fix to the desired images. 或者为IE创建一个if语句,您只需将.fix添加到所需的图像。 The .fix is in your CSS file, adding to images a background of the desired color. .fix位于CSS文件中,为图像添加所需颜色的背景。

if ($.browser.msie && $.browser.version <= 8 )
{
$('#gallery img').addClass('fix');
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM