详解HTML的input 标签及其禁用方法

2020-04-17 07:51:32易采站长站整理

input.disabled{   
    border: 1px solid #DDD;   
    background-color: #F5F5F5;   
    color:#ACA899;   
}  

最终结果:
 

CSS Code复制内容到剪贴板

//Chrome Firefox Opera Safari IE9+   
input:disabled{   
    border: 1px solid #DDD;   
    background-color: #F5F5F5;   
    color:#ACA899;   
}   
//IE8-   
input[disabled]{   
    border: 1px solid #DDD;   
    background-color: #F5F5F5;   
    color:#ACA899;   
}   
//IE6 Using Javascript to add CSS class "disabled"  
* html input.disabled{   
    border: 1px solid #DDD;   
    background-color: #F5F5F5;   
    color:#ACA899;   
}  

注意:IE8 bug
由于IE8 不识别 :disabled 导致input[disabled],input:disabled样式失效,可以考虑单独来写,或者直接使用input[disabled]。;IE9及以下无法改变字体颜色。

    Demo