简体   繁体   English

如何将CSS仅应用于IE 8及以下版本

[英]How do I apply css to only IE 8 and below

I want some of my styles to only be applied to IE 8 and lower. 我希望我的某些样式仅适用于IE 8及更低版本。 I also only want to change my style sheet and NOT my html. 我也只想更改样式表,而不是html。 Is this possible? 这可能吗?

Here is my style I want to apply to only IE 8 and lower (I don't want to change IE 9 or 10) 这是我的样式,我只想应用于IE 8及更低版本(我不想更改IE 9或10)

.ui-icon-searchfield:after {
        background-color: #000000;
        background-color: rgba(0,0,0, 0.4);
        background-image: url(images/icons-18-white.png);
        background-repeat: no-repeat;
        -webkit-border-radius: 9px;
        border-radius:  9px;
        filter: alpha(opacity=40); 

} }

I only want the very last style to be used on IE 8 and lower 我只希望将最新样式用于IE 8及更低版本

Two options: 两种选择:

1: 1:

.ui-icon-searchfield:after {
    background-color: #000000\9; /* IE8 and below */  
    background-color: rgba(0,0,0, 0.4)\9; /* IE8 and below */  
    background-image: url(images/icons-18-white.png)\9; /* IE8 and below */  
    background-repeat: no-repeat\9; /* IE8 and below */  
    -webkit-border-radius: 9px\9; /* IE8 and below */  
    border-radius:  9px\9; /* IE8 and below */  
    filter: alpha(opacity=40)\9; /* IE8 and below */  
}

2: 2:

<!--[if IE 6]>
/*According to the conditional comment this is IE 6*/
  .ui-icon-searchfield:after {your stuff}
<![endif]-->
<!--[if IE 7]>
/*According to the conditional comment this is IE 7*/
  .ui-icon-searchfield:after {your stuff}
<![endif]-->
<!--[if IE 8]>
/*According to the conditional comment this is IE 8*/
  .ui-icon-searchfield:after {your stuff}
<![endif]-->

My suggest is the second(Conditionals) 我的建议是第二个(视情况而定)

Check out this link. 查看此链接。 It has all the information needed to work on IE CSS. 它具有在IE CSS上工作所需的所有信息。

https://css-tricks.com/how-to-create-an-ie-only-stylesheet/ https://css-tricks.com/how-to-create-an-ie-only-stylesheet/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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