Internet Explorer 11,如何设置只读样式?



我正在仔细检查我的网站是否一切正常,还有其他浏览器。

我注意到在Chrome中我可以以只读方式设置样式,但在Internet Explorer中您无法设置样式。

我通常禁用了输入字段,但此只读字段需要只读才能将其放入数据库。

如果不可能。我希望只读输入不会通过鼠标单击聚焦。因为我现在有一个带有占位符的只读输入字段。如果我在只读输入内单击,文本会消失。因此,如果我在其中单击,输入可能会更改。如果我的第一个问题做不到,可以防止这种情况吗?

感谢您的时间,我很感激。

HTML 只读(需要它是只读的,因为我必须发布它(

<input id='overNightRate' type='text' name='overNightRate' class='form-control disabledDesign' placeholder="Bedrag word berekent" readonly/>

.CSS

.disabledDesign:read-only{background-color:#003c85;
color: white;
opacity: 1;}

而且我有更多的输入字段,这些字段是相同的,但只是计算某物的总和。这也需要只读,因为它需要将输入数据存储到数据库中。

如果需要readonly,我相信IE 11支持attr选择器:

.disabledDesign[readonly='readonly'] {
background-color: #003c85;
color: white;
opacity: 1;
pointer-events: none;
}
<input id='overNightRate' type='text' name='overNightRate' class='form-control disabledDesign' placeholder="Bedrag word berekent" readonly="readonly" />

编辑:在IE11上测试并按预期工作。

最新更新