简体   繁体   中英

Are both -ms-filter and filter used for gradients in IE?

I am using the following code but now I don't know if I need to use both of these:

filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#46494F', endColorstr='#141A1E',GradientType=0);

-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#46494F', endColorstr='#141A1E',GradientType=0)";} 

What's making me more confused is that VS2010 reports the following message "Validation CSS 2.1 - filter is not a known property name."

Has anyone experienced similar issues using these? How about with IE9 and above? Are these still used or is that browser using new CSS standards?

Hope someone knows more than me about this.

Thanks,

filter and -ms-filter are proprietary CSS properties invented by Microsoft for use with IE only, so the validation messages aren't an issue.

filter is used for IE older than 8, while IE8+ adopts the prefixed version, -ms-filter .

The reason Microsoft replaced filter with -ms-filter in IE8 was because they needed to make incompatible syntax changes to it.

-ms-filter allows you to wrap the whole filter string in quotes, whereas the older filter style doesn't.

This is important because many filters include strings such as progid: (which is invalid CSS due to the colon). Including these filters in a filter style, without the quotes can cause other browsers to choke on the entire stylesheet.

IE9 has dropped support for both filter and -ms-filter entirely. If you want to use these effects in IE9 you have to use standard CSS3.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM