开发者

Generic way of making CSS work on IE only without separate CSS sheet

开发者 https://www.devze.com 2023-04-12 08:59 出处:网络
I was just wondering about CSS for IE.Typically we have a separate style sheet andbut I wondered if there was any way of incorporating different options in the same sheet, e.g.:

I was just wondering about CSS for IE. Typically we have a separate style sheet and but I wondered if there was any way of incorporating different options in the same sheet, e.g.:

h1 {
    /* font size for Firefox to be 22px */
    font-size: 22px;
    /* font size for Internet Explorer to be 20px */
    font-size: 20px;
}

I.e.开发者_运维问答 my question is it it possible to have all the options in one CSS sheet with conditions.


Just so it's posted as an answer (wasn't 100% sure it's what you wanted)...

Check out http://css-tricks.com/132-how-to-create-an-ie-only-stylesheet/ and look beneith the Hacks heading for in-line styles that are applicable only to specific IE versions. e.g.

IE 6 only

* html #div {
    height: 300px;
}

IE 7 only

*+html #div {
    height: 300px;
}

IE 8 only

#div {
  height: 300px\0/;
}

IE 7 & 8 Only

#div {
  height: 300px\9;
}

Non-IE 7 Only

#div {
   _height: 300px;
}

Hide from IE6 & Lower

#div {
   height/**/: 300px;
}

html > body #div {
      height: 300px;
}

Quoted for reference and redundancy (in case the link breaks in the future).


You can use these hacks http://dimox.net/personal-css-hacks-for-ie6-ie7-ie8/


If you want to run some server-side code, you should use a CSS Preprocessor such as LESS.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号