Can you define an 开发者_JAVA百科[if IE7] in the actual stylesheet? Or must you do it in the html to pull a different SS?
Thanks! (Google isn't being kind to me =/)
You will have to do that in the HTML code. The only way to do such a thing directly in CSS is by using certain CSS-Selectors, which only IE7 recognizes. If I'm not mistaken, that would be
*+html #yourselector {}
for IE7.
You must do it in the HTML. There are various hacks to achieve similar behavior in CSS, but avoid them, as they may break in future browser versions.
It has to be in the html. IE was able to work with CSS Expressions, but since it's entirely proprietary, and deprecated as of IE8, it won't, unless the browser is IE5-7, or running in compatibility mode with IE5 or 7, be executed/interpreted.
Plus, honestly, it's easier to use in the (x)html anyway.
For use in the (x)html, conditional comments, not CSS Expressions, can be used to achieve the aims of selectively serving CSS (or other content) to IE browsers. CSS Expressions may, or may not, be able to achieve that (or similar) functionality in the stylesheet, but they are not a good idea. For many reasons, deprecation, and their being proprietary, being only two of them.
精彩评论