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?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
DD_belatedPNG.js works very well
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.
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.
IE PNG Fix v2.0 has support for full alpha+
position
/repeat
.This is a new technique that has popped up in the last month or so. From the page:
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!).