如何将css仅应用于IE 8及更低版本

R D*_*abh 1 css internet-explorer

我希望我的一些样式仅适用于IE 8及更低版本.我也只想改变我的样式表,而不是我的HTML.这可能吗?

这是我的风格我想申请只有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); 
Run Code Online (Sandbox Code Playgroud)

}

我只希望在IE 8及更低版本上使用最后一种风格

Emi*_*ort 5

两种选择:

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 */  
}
Run Code Online (Sandbox Code Playgroud)

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]-->
Run Code Online (Sandbox Code Playgroud)

我的建议是第二个(条件)