Is it possible to write IE 8 specific styles for few elements without using js or jquery? I have a requirement in which line-height is used , this works fine firefox and chrome where as in IE8 i want to reduce 2 px of line-height can i do this in style class ?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Yes, you can use Paul-Irish's way of targetting IE Browsers:
<!--[if lt IE 7]> <html class="ie ie6 lte9 lte8 lte7"> <![endif]-->
<!--[if IE 7]> <html class="ie ie7 lte9 lte8 lte7"> <![endif]-->
<!--[if IE 8]> <html class="ie ie8 lte9 lte8"> <![endif]-->
<!--[if IE 9]> <html class="ie ie9 lte9"> <![endif]-->
<!--[if gt IE 9]> <html> <![endif]-->
<!--[if !IE]><!--> <html> <!--<![endif]-->
Or the new one:
<!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
<!--[if IE 7 ]> <html class="ie7"> <![endif]-->
<!--[if IE 8 ]> <html class="ie8"> <![endif]-->
<!--[if IE 9 ]> <html class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class=""> <!--<![endif]-->
So for just targetting IE 8, you can use:
<!--[if IE 8 ]> <html class="ie8"> <![endif]-->
回答2:
Use this inside of head tag:
<!--[if IE 8]>
<link rel="stylesheet" href="ie8.css" />
<![endif]-->
回答3:
Css conditional comments will help you do this
<!--[if IE 8]>
IE 8 stuff here
<![endif]-->
Have a look at http://www.quirksmode.org/css/condcom.html for more info.