Forum Moderators: open
I have a problem to get transparency to work ok in IE.
Anyone have any idea to fix it correct?
I have attached pictures of it, in Firefox it works out perfect but in IE its just plain color.
The light brown color you see in IE is a .PNG image.And its floating over the background image. As you can see the transparency is perfect in Firefox
<snip>
Any suggestions on how to fix it?
Regards
Graphixx
[edited by: encyclo at 10:05 pm (utc) on Aug. 14, 2006]
[edit reason]
[1][edit reason] no screenshot links please, see forum charter [/edit] [/edit][/1]
The only approach I know of, if indeed this is the issue for you, is to go back to the image source files and use 8-bit PNG.
You mean GIF, right?
A GIF will work, but I did mean PNG. I just did a test (no IE hacks or helper apps) and can confirm that IE6 definitely supports transparency in at least some PNG-8 images. Just not full alpha transparency in PNG-24 images. PNG-8 often gives sightly better compression than GIF, and that's why I mentioned the option.
Digging a bit further, I see that it is possible to create a PNG-8 image that IE does not support. Here's a test page for various flavors of PNG images, and IE will choke on the bottom 4 PNG-8 images:
[libpng.org...]
I'm still not clear on what the trouble is with these. The page says:
All of these images are interlaced, have transparency, and should be rendered with the same green background as the page. If the images have obvious rectangular borders (due to the color specified in the bKGD chunk), the browser is broken... These images are quarter-scale, interlaced, RGBA-palette (8-bit) versions of the original 32-bit RGBA images; each is between 35k and 70k... The conversion to 8-bit palette mode was accomplished by means of modified versions of some of the NetPBM tools.
Internet Explorer [Microsoft] (Win32, Solaris/X, HP-UX/X) - version 4.0b1 and later; read-only; full alpha support as of version 7.0b1 (screenshots), but broken alpha support in earlier versions;11. simple transparency only, with bad threshold for transparency vs. opacity, and only for palette images; completely fails to render some transparent palette images (e.g., bottom four here), apparently due to nearly-but-not-quite-opaque alpha values; non-palette images are rendered fully opaque against a light gray background;
[libpng.org...]
So how to be get alpha PNG support in IE? Well, it turns out that IE can farm images out to DirectX to be applied almost as a texture to the webpage. The way the MS previously recommended was to create a blank gif of the right size and apply the alpha transparent PNG via the use of their 'filter' system. This unfortunately breaks stuff for other browsers which can support alpha PNGs (i.e. anything newer than Netscape 4.0). Luckily there's a now famous 'behavior' that'll fix this automatically for you. If you search the web for 'png behavior' you'll find it easily enough. It's a plug and play solution that finds PNGs in your page and runs them through the filter system automatically.
to the best of my knowledge a 24bit PNG can't have transparency as it's not palettised
Thanks for the precision, Robin -- and I'm pretty sure you've got it right.
Since alpha transparency in a truecolor image (RGB) is created by adding an alpha channel to a PNG-24 image (making it RGBA) there are many pages on the web that simply call it a PNG-24 image with transparency. I fell into a superficial understanding.
An important thing to note here is that Photoshop's PNG output is absolutely atrocious in terms of file size. Fireworks is much better but still not perfect. It's always worth running files through a compressor (I use OptiPNG but PNGCrush is fine as well) before uploading. This doesn't remove any quality - simply organises the chunks in a more efficient way. I can usually get a 10% improvement in filesize from Fireworks with this, maybe 50% on Photoshop's output.
See [libpng.org...]
<edit reason - offer the link>
[edited by: tedster at 3:11 pm (utc) on Aug. 16, 2006]
2) Internet Explorer 6 and older do not support that alpha channel and draw (semi-)transparent pixels in a awful greenish color. In IE7 that's fixed [blogs.msdn.com].
3) There is a workaround [homepage.ntlworld.com] for PNG transparency available for IE5.5 and up. It's ugly, it uses JavaScript and an proprietary AlphaImageLoader. The fix does not work for PNG CSS background images.
[edited by: Hanu at 6:24 am (utc) on Aug. 17, 2006]
MatthewHSE: I've had good results with this script [koivi.com].
I've tried pretty much every solution and that one is the best. Especially since it handles both images and CSS background images, and it runs server side, so it's quick.
"seoArt: sometimes there isn't. A concrete example - recently I had a design that called for antialiased rounded buttons that could sit on any of 12 different colours, with more in the pipeline. I would have had to make up 12 different styles of buttons (one for each styles). Alternatively I just made one 32-bit alpha PNG and it all worked fine. "
You just described an alternate way of doing it - making 12 different styles of buttons. How long would that take?
Is there a problem with this method in IE? Does it not work in certain browsers?
myElement {
width: 97px;
height: 26px;
background /**/: transparent url(images/tiara_up.png) top left no-repeat;
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader
(src='images/tiara_up.png',sizingMethod='scale');
} Sorry if I'm missing the point...
<?php $msie='/msie\s(5\.[5-9]¦[6]\.[0-9]*).*(win)/i'; if(!isset($_SERVER['HTTP_USER_AGENT']) ¦¦!preg_match($msie,$_SERVER['HTTP_USER_AGENT']) ¦¦ preg_match('/opera/i',$_SERVER['HTTP_USER_AGENT'])){echo('
//outputs the following in Other Browsers
<img src="assets/images/latestnews.png" alt="latest news" />
');}else{echo('
//outputs the following in IE
<img src="assets/images/home/spacer.png" alt="product information" style="width: 158px; height: 28px; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'/assets/images/latestnews.png\', sizingMethod=scale);" />
');}?>
Kind of chunky, but it's nice if used sparingly.
I've had good results with this script [koivi.com].
It bears repeating... For me, that script was the last stop on a long road of attempts at a simple drop-in solution for alpha transparent PNGs. I'm not affiliated with the site, but I also recommend it.
I don't even have to think about PNG transparency anymore.