禁用和检查单选按钮标签的CSS选择器

Gau*_*tam 2 css css-selectors

我正在使用C#.net我的情况是我的屏幕上有一些预先检查和禁用的单选按钮列表.我想要的是对于选中和禁用的单选按钮,文本应该是绿色和粗体,因为我已经编写了以下CSS类

 input[type="radio"]:disabled  +label 
 {
     color: Gray;
 } 
 input[type="radio"]:checked  +label 
 {
     font-weight: bold; 
     color: Green;
 }
 input[type="radio"]:enabled  +label 
 {
     color: Black;
     font-weight: normal;
 } 
Run Code Online (Sandbox Code Playgroud)

这适用于firefox,IE9和chrome.当我在IE 8中尝试它时,问题就出现了..那时css没有被应用.有没有办法对IE 6,7和8应用相同的效果?PS我不能使用jquery或javascript这个..唯一可行的选择是使用css

hai*_*770 6

除了:enabled伪选择器之外,您可以使用CSS2获得相同的结果,attribute selectors并使IE7及以上版本正常工作:

 input[type="radio"][disabled] + label 
 {
     color: Gray;
 } 

 input[type="radio"][checked] + label 
 {
     font-weight: bold; 
     color: Green;
 }
Run Code Online (Sandbox Code Playgroud)

有人会争辩说:enabled选择器是redudant,并且实际上是input[type=radio] + label没有disabled/checked定义属性时的默认样式.