IE shows black border around PNG when faded in

末鹿安然 提交于 2019-11-28 03:29:33

问题


Here is my site: http://smartpeopletalkfast.co.uk/ppr6/

I have PNGs with transparency fadein with jQuery. IE8 (havnt tested with others yet) is showing black borders around the PNGs while they fade in. I know this is a recognized issue and I've tried a few methods without luck.

However, I've noticed that the heart (the last image to load) doesn't have the black borders. Why is this one OK? Hopefully if I figure out why I can use it to fix the others.

Thanks

UPDATE

I'd played around with code so much I hadn't realized I'd unintentionally disabled the fade in of the heart, so thats why no borders.

It's a weird issue this one. In all the forums I've looked at their are solutions that seem to work for some people but not for others.


回答1:


I know this thread is very old, anyways I found this post which worked great for me, it completely removes the black borders from PNG's in IE7, IE8.

.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 */ 
}

You can find it int this thread http://www.sitepoint.com/forums/showthread.php?590295-jQuery-fadein-fadeout-of-transparent-png-in-IE7-and-Chrome




回答2:


add this attribute to your tag like this

<img src="/someimage.png" alt="yourImageDesc" style="border-style: none" />



回答3:


Using a PNG-8 worked for me. Their is a slight white border to the image which is in the actual file not a browser issue but in my case this looks fine.




回答4:


put background color

background: #E1AE07;
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF)"; /* IE8 */   
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF);   /* IE6 & 7 */      
    -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
    filter: alpha(opacity=50);
    -khtml-opacity: 0.50;
    -moz-opacity: 0.50;
    opacity: 0.50;



回答5:


i've had the same issue setting the opacity of an element using jquery as in $('div').css('opactiy',0.5); i was able to fix it by setting a solid background color for the 'div' in concern.

simple demonstration: http://jsfiddle.net/mwXs3/3/ (compare this in firefox and ie8)...



来源:https://stackoverflow.com/questions/4972818/ie-shows-black-border-around-png-when-faded-in

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!