views:

35

answers:

3

I am using the ms proprietary css property "filter" to control the opactiy of an element.

#square2
{
    filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=50)";
    zoom:1;
    padding:10px;
    border:solid 5px #0cc;
    height:200px;
    width:400px;
    background-color:#cc0;
    color:#c0c;
    font-size:2em;
}  

The problem is highlighted in IE7 (running IE8 in IE7 Browser Mode). The filter property isn't considered to be 'closed' by the parser. The filter property therefore contains all other properties that suceed it.

I wanted to post a screen shot at this point but noobs ain't allowed!

I understand that I can simply move the filter property to the end of the css selector, but this is a simplified version of the problem - and that is not a realistic solution.

The problem is worsened when it is followed by another css selector. The new css selector itself gets caught up in the previous selector's filter property. The new selector then takes no effect at all, as though it wasn't there.

I am simply looking to make IE7 recognise where the end of the filter property is.

Your help is much appreciated.

Thanks

+2  A: 

You don't put quotes around it in your CSS declaration. Just

filter:progid:DXImageTransform.Microsoft.Alpha(opacity=50);

Source: http://msdn.microsoft.com/en-us/library/ms532967(VS.85).aspx

Robert
+1 for MSDN docs.
BoltClock
Thanks for the quick response! I tried with and without the quotes. The filter still eats at least one property into the next selector...
Nick
+1  A: 

Avoid the quotes-vs-no-quotes IE7/IE8 syntax issues by using the simplified form of the alpha filter:

filter: alpha(opacity=50);
bobince
A: 

The Alpha filter was just to simplify the problem (I am really using the Matrix filter) so that fix doesn't apply.

The quotes/no-quotes fix didn't work either so the answer I came up with was to remove the filter style from the stylesheet and place it in a style tag on the master page. This allowed me to use to mutliple selectors with the filter property - each in their own style tag on the page.

<html>
<head>
<style type="text/css">
      #square2{padding:10px;filter:"progid:DXImageTransform.Microsoft.Alpha(opacity=50)";}
</style>
</head>
</html>

This made the IE7 parser recognise the end of the property, but has the downside of having to maintain style in more than one place.

Nick

Nick