html - 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 上测试并按预期工作。
推荐阅读
- psycopg2 - Psycopg2.connect:数据库不存在
- python - 熊猫 dropna 没有按预期工作
- python - 输入带有空格的名称并进行验证
- python - 使用 selenium webdriver 和 python 下载文件的正确方法是什么?
- python - Python 3:变量范围
- sql - postgreSQL/PostGIS 数据库:表继承
- python - 如何在 Tkinter 的 ScrolledText 小部件中绑定“ENTER KEY”
- windows - Sourcetree“git clone”给出错误“致命:遇到ArgumentOutOfRangeException。指定的参数超出了有效值的范围。”
- c++ - 如何检查特定流程是否为关键流程?
- asp.net-mvc - ASP.NET MVC 使用 spotify web api