@LadyC never!

PNGs, the AlphaImageLoader Filter, and hasLayout

I recently wrote an article discussing how to use PNGs effectively in all browsers (including IE6). For work, I had to slice a site that used a lot of PNGs, and I ran into something that I had never encountered before.

I was trying to use the Microsoft proprietary AlphaImageLoader Filter because they background images were PNGs that were going to scale to fit the background. The div that I was setting the PNG as the background to, did not have a height or width specified. Apparently, to use the AlphaImageLoader property, the element that you are using it on must have another Microsoft propriety property: hasLayout.

From the Microsoft Developer Network Site:

The object that the filter is applied to must have layout before the filter effect will display. You can give the object layout by setting the height or width property, setting the position property to absolute.

An Example

I am going to use the same working example I used in my Ultimate PNG Guide. But this time, I am going to add the following to the head of the page:

<style type="text/css">
div#container div.inner { width: auto; }
</style>

Obviously not how you would want to really add that style to the page, but I am just trying to prove that in IE6, to use a PNG with the AlphaImageLoader Filter applied, the element must have layout. So here is the new page, which should be broken in IE6.

So there you have it, remember to give elements layout if you are going to use the AlphaImageLoader Filter.

Share This:
  • del.icio.us
  • Digg
  • Twitter
  • Facebook
  • StumbleUpon
  • Google Bookmarks
  • NewsVine
  • Technorati
  • Reddit
  • LinkedIn

RSS feed of comments for this entry

Speak Your Mind

* Denotes Required Field

  1. To post code snippets, use <pre><code>YOUR CODE HERE</code></pre>
Me, Trevor Davis. My blue steel face…

Hi, I’m Trevor Davis

I’m a 25 year old Front-End Developer living in Arlington, VA. I work full-time at Viget Labs and freelance on the side.

I specialize in CSS, HTML, jQuery, WordPress & ExpressionEngine. See more of my work, and then hire me.

Recent Work

  • 4th District IBEW Health Fund
  • Employers Council on Flexible Compensation
  • Monica Davis
  • The National Christmas Tree
  • Matrix Group International
  • The MatriX Files
  • Wireless Career
  • George Washington Wired
  • Direct Selling 411
  • Makeup Bizz
  • InstallNET
  • National Park Foundation
See More of My Work

Asides