Is there a JavaScript PNG fix for IE6 that allows

2020-05-27 03:31发布

I've seen a few fixes for allowing PNG images to have transparency in Internet Explorer 6, but I've yet to find one that also allows you to set the background position in CSS. If you use sprites, it's a deal-breaker. I've resorted to using GIF's (which are not as high quality), not using transparent images at all, or serving a completely different stylesheet to IE6. Is there a fix for IE6 that allows for PNG transparencies AND background positioning?

6条回答
叼着烟拽天下
2楼-- · 2020-05-27 04:06

DD_belatedPNG.js works very well

查看更多
Melony?
3楼-- · 2020-05-27 04:16

You can actually use pure CSS to get positioned background images with alpha transparency in IE6 by taking advantage of IE6's alpha filters and the CSS clip property. Julien Lecomte describes the technique on his blog.

Note that this technique does result in a performance hit for each use of an alpha filter.

查看更多
倾城 Initia
4楼-- · 2020-05-27 04:18

Yes. Convert your images to use indexed pallets (png256). You can support transparency (just like gif), but not an alpha channel.

You can do this using Irfanview and the pngout plugin, pngquant or pngnq.

The YUI performance team also did a great presentation that covers this an many other image optimization concepts.

查看更多
【Aperson】
5楼-- · 2020-05-27 04:19

IE PNG Fix v2.0 has support for full alpha+position/repeat.

查看更多
小情绪 Triste *
6楼-- · 2020-05-27 04:28

This is a new technique that has popped up in the last month or so. From the page:

In this script image tags are supported, both with and without a blank spacer GIF, and background image PNGs may be positioned, as well as repeated, even if they're smaller than the content element they're in.

查看更多
萌系小妹纸
7楼-- · 2020-05-27 04:28

When the background is static I use TweakPNG to change the Background Color chunk in the PNG to the correct color (instead of the default gray color). Any regular browser will ignore this because the alpha channel overrules it, but IE6 and lower will use that color instead of the alpha channel.

This means we have transparency in IE7+ while degrading nicely in IE6 and lower. And all css positioning and repeating are possible (because there are no hacks!).

查看更多
登录 后发表回答