IE8窒息CSS3 - 避免它不读取文件的其余部分

时间:2012-10-18 18:41:59

标签: css internet-explorer css3

我有以下css:

.mcRow input.mcCheckbox {
    display:none;
}

.mcRow input.mcCheckbox + label {
    background: url('/media/img/pt/dhtml/mc_off.gif') no-repeat;
    height: 19px;
    width: 19px;
    display:inline-block;
    padding: 0px;
    padding-left: 20px;
    width: auto;
}

.mcRow input.mcCheckbox:checked + label {
    background: url('/media/img/pt/dhtml/mc_on.gif') no-repeat;
}​

.mcRow input.mcCheckbox.checked + label {
    background: url('/media/img/pt/dhtml/mc_on.gif') no-repeat;
}​

由于IE8与CSS3不兼容,我已经包含了一个用jQuery切换的备份.checked类。即使JS被破坏,我也希望我的自定义复选框显示,因此我想保留CSS3中包含的:checked伪选择器。

上述顺序在IE 8中不能很好地运行。它似乎忽略了:checked语句之后的所有内容。

.mcRow input.mcCheckbox + label {
        background: url('/media/img/pt/dhtml/mc_off.gif') no-repeat;
        height: 19px;
        width: 19px;
        display:inline-block;
        padding: 0px;
        padding-left: 20px;
        width: auto;
    }

    .mcRow input.mcCheckbox.checked + label {
        background: url('/media/img/pt/dhtml/mc_on.gif') no-repeat;
    }
​
    .mcRow input.mcCheckbox:checked + label {
        background: url('/media/img/pt/dhtml/mc_on.gif') no-repeat;
    }​

工作得很好。我害怕将此添加到文件中,并且有人在此声明之后添加其他CSS,不知道在IE8中是否都不会读取它。 :(我该怎么办?

1 个答案:

答案 0 :(得分:1)

嗯,你当然可以在CSS中发表评论。

然而,更好的方法可能是简单地使用IE条件注释来在IE中不包括该代码< 9。