IE opacity filter – another reason to hate IE

Posted by
Ziwei

Posted On
Jan 27 2010 1:33 am

Add Comments
Posted in Tutorials

Ran into some hair-tearing problem with IE again. This time with its opacity filter. Apparently, you have to declare the width and height of the element where you are applying the filter for it to work even though a block element is suppose to get its width and height from its contents, at least, that’s how it works for safari and firefox.

This issue has been observed in IE 7.0 and IE 6.0, IE 8.0, however do not exhibit this problem.

See the example below, you will need to view it in the culprit browser which is IE 7 or below to see the problem and solution.

Opacity filter before setting the width and height

  1. <div style="display:block; filter:alpha(opacity=50); background-color:#000;">
  2. <div style="height:100px; width:100px; padding: 20px; color:#FFF">50% transparency</div>
  3. </div>

50% transparency

The above example will render as a solid black box with no transparency in IE 7.0 and below

Opacity filter after setting the width and height

  1. <div style="display: block; filter:alpha(opacity=50); background-color: #000000; height: 100%; width: 100%;">
  2. <div style="padding: 20px; height: 100px; width: 100px; color: #FFF;">50% transparency</div>
  3. </div>

50% transparency

At last the opacity filter is working now.

Comments ( 0 )

No Comment to “IE opacity filter – another reason to hate IE” so far

Post Comment

Remember! Spamming is for losers

Trackback from your own website