Multiple CSS filters in IE

后端 未结 3 1777
一个人的身影
一个人的身影 2021-02-14 08:44

I\'m just wondering that it is possible to apply two different filters in IE using CSS. So, I need to use a transparent PNG and also some opacity to a div. Is it po

3条回答
  •  误落风尘
    2021-02-14 09:35

    Sorry, but the chosen answer above is not correct. You can apply multiple filters in IE, but they need to be separated by one or more spaces.

    A comma before the spaces will also work, but only if it follows a closing bracket. So IE 4.0 filters without parameters such as gray don't work in this case. Best to stick to spaces only as a separator.

    If you go to the link given above: http://msdn.microsoft.com/en-us/library/ms532847(v=vs.85).aspx, and click on the following example link (in IE, of course), you see that both a rotation and a blur are applied to the second image. From "view source", the image tag is:

    ocean beach
    

    I have somewhat successfully simulated the "spread" of a box shadow in IE7 and 8 (although successful depends on how acceptable you think it looks), using:

    filter: progid:DXImageTransform.Microsoft.Shadow(Color=#c5c1ae, Strength=10, Direction=0)
            progid:DXImageTransform.Microsoft.Shadow(Color=#c5c1ae, Strength=10, Direction=90)
            progid:DXImageTransform.Microsoft.Shadow(Color=#c5c1ae, Strength=10, Direction=180)
            progid:DXImageTransform.Microsoft.Shadow(Color=#c5c1ae, Strength=10, Direction=270);
    

    so that a shadow spreads from all sides of a div. I've also combined shadows on div's that contain gradients. This does not all come without its own peril, however. In the case above, the shadows have layout, and you have to adjust margins to accommodate their size. Also, with IE being IE, combinations of some of these filters can have unintended consequences, leading to developing workarounds, abandoning approaches, and the pulling out of one's hair.

    In your original examples in your question, if you list more than one filter, the previous one will be overridden by the succeeding one, just like any other CSS property. In your second example, "!important" needs to be completely at the end of the style, or the entire block of CSS is discarded since it is misformatted. (Actually, !important needs to be thrown out completely. About the only reason you would ever need to use it is if you are developing third party code and need to defend your tags from another !important-happy developer over whom you have no control. If your style is being unintentionally overridden, you need a more specific declaration.)

提交回复
热议问题