2010-05-24 70 views
1

我知道,我知道IE6对不对?那么不管论证有多强烈 - 我现在必须请IE6。无法在IE6中设置输入字段,为什么?

我有一个文本输入字段。我的风格是字体和背景颜色。但我无法让IE6显示我正在改变的更改。这里是我的标记和CSS。

<style> 
    input[readonly='readonly'], input.readonly { 
    color:red !important; 
    background:#EBEBE4 !important; 
    border:solid 1px #7F9DB9 !important; 
    cursor:default; 
} 
</style> 

这里是我的表格。

<form name="mainform" method="post" action="/link.aspx" id="mainform"> 
    <div class="section"> 
     <label for="shipFirstName">First Name:<abbr title="Required field">*</abbr></label> 
     <input type="text" name="shipFirstName" id="shipFirstName" value="Rich" readonly='readonly' class='readonly' maxlength="13" /> 
     <label for="shipFirstName">Last Name:<abbr title="Required field">*</abbr></label> 
     <input type="text" name="shipLastName" id="shipLastName" value="Sturim" readonly='readonly' class='readonly' maxlength="26" /> 
    </div> 
</form> 

我知道问题出在选择

input[readonly='readonly'], input.readonly 

但我不知道我有什么做的就是IE6承认“只读”类。

任何想法?

回答

4

IE6被input[readonly='readonly']选择器弄糊涂,并将整个规则视为语法错误。你将不得不制定两个不同的规则,使其工作:

<style> 
    input[readonly='readonly'] { 
    color:red !important; 
    background:#EBEBE4 !important; 
    border:solid 1px #7F9DB9 !important; 
    cursor:default; 
} 
    input.readonly { 
    color:red !important; 
    background:#EBEBE4 !important; 
    border:solid 1px #7F9DB9 !important; 
    cursor:default; 
} 
</style> 
+0

完美 - 感谢马丁! – rsturim 2010-05-24 19:31:23

+0

我应该提到,在这种特殊情况下,第一条规则显然是多余的。我刚刚从类似的情况中复制了这种情况,只读类添加了特定于IE6的脚本,在这种情况下,需要复制该规则。 – Martin 2010-05-24 21:29:30

+0

感谢马丁,单独的规则的东西扔给我。上帝是IE6有史以来PITA! – mdgrech 2011-09-09 21:36:02

1

使用

input[readonly] { 
    // stuff 
} 
0

IE6不支持属性选择器,我想你只是需要摆脱input[readonly='readonly'],这可能会解决你的问题。

2替代解决方案:

  • 添加类属性的input(就像你一样)
  • 使用JavaScript。
相关问题