May*_*yur 37 css internet-explorer
可能重复:
如何在CSS中执行IE条件?
我如何才能将以下规则应用于IE?
.abc {
float:left;
height:0;
margin:0 10px;
width:0;
/*Apply these rules for IE only*/
position:absolute;
left:30;
top:-10;
/*Apply these rules for IE only*/
}
Run Code Online (Sandbox Code Playgroud)
Pek*_*ica 29
在IE9以及包括IE9在内的浏览器中,这是通过条件注释完成的.
<!--[if IE]>
<style type="text/css">
IE specific CSS rules go here
</style>
<![endif]-->
Run Code Online (Sandbox Code Playgroud)
DAS*_*RiD 23
避免加载多个CSS文件或使用内联CSS的好方法是根据Internet Explorer的版本将类交给body标记.如果你只需要一般的IE黑客,你可以做这样的事情,但它可以扩展为特定于版本:
<!--[if IE ]><body class="ie"><![endif]-->
<!--[if !IE]>--><body><!--<![endif]-->
Run Code Online (Sandbox Code Playgroud)
现在在你的css代码中,你可以简单地做:
.ie .abc {
position:absolute;
left:30;
top:-10;
}
Run Code Online (Sandbox Code Playgroud)
这也使您的CSS文件有效,因为您不必使用脏(和无效)CSS黑客.
Joh*_*Del 18
一种快速的方法是使用以下内容,即你想要聚焦(检查注释),在你的css文件里面(margin-top,设置你喜欢的任何css属性):
margin-top: 10px\9; /*It will apply to all ie from 8 and below */
*margin-top: 10px; /*It will apply to ie 7 and below */
_margin-top: 10px; /*It will apply to ie 6 and below*/
Run Code Online (Sandbox Code Playgroud)
更好的方法是检查用户代理或条件if,以避免在其他浏览器中加载不必要的CSS.
小智 5
如前所述,我更喜欢使用单独的文件来表示规则.
<!--[if IE]><link rel="stylesheet" type="text/css" href="ie-style.css"/><![endif]-->
Run Code Online (Sandbox Code Playgroud)
在其中,您可以为不同版本设置规则,即使用:
.abc {...} /* ALL MSIE */
*html *.abc {...} /* MSIE 6 */
*:first-child+html .abc {...} /* MSIE 7 */
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
110955 次 |
| 最近记录: |