问:
由于特殊情况,我想将任何禁用控件的颜色更改为黑色,就像启用控件一样,我尝试了很多解决方案,例如使文本框只读但是(由于这种情况的某些原因,我不想要这个解决方案),我使用 Css 文件,除了文本的颜色之外,所有的东西都改变了,请问如何改变颜色更清晰。
编辑::针对 IE 测试
我的 CSS:
input[disabled] { border:solid 1px red; background-color:White;color:red !important;font-weight:bold;font-size:medium; }
我的 .aspx 示例::
<title></title>
<link href="StyleSheet1.css" rel="stylesheet" type="text/css" />
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
<br />
<br />
<asp:TextBox ID="TextBox1" runat="server" Enabled ="false"
></asp:TextBox>
</div>
</form>
`
最佳答案
使用以下 CSS2 选择器:
input[disabled=disabled] {
/* your style */
color: #fff !important;
}
关于javascript - 如何更改禁用控件的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4724665/