[英]How can I get a CSS class selector to override the input[readonly] selector?
I have the following CSS to insure that all readonly textboxes have the background color set to grey... 我使用以下CSS来确保所有只读文本框的背景色均设置为灰色...
input[readonly]
{
background-color: #ddd;
}
But now I want to override that style for a TextBox with CssClass="WarningText" but the following does not work... 但是现在我想使用CssClass =“ WarningText”为TextBox覆盖该样式,但是以下操作不起作用...
.WarningText
{
background-color: #ffff99;
}
How can I get the .WarningText style to override the default input[readonly] style? 如何获取.WarningText样式以覆盖默认的input [readonly]样式?
You will want to use valid CSS Selectors so like @paulie_d said input[readonly].WarningText
should do what you are expecting it to do. 您将要使用有效的CSS选择器,例如@paulie_d表示
input[readonly].WarningText
应该执行您期望的操作。 http://www.w3schools.com/cssref/css_selectors.asp http://www.w3schools.com/cssref/css_selectors.asp
Use this. 用这个。
input[readonly="readonly"].WarningText
{
background-color: #ffff99;
}
You need to chain the attribute and class selector(s) like so: 您需要像这样链接属性和类选择器:
input[readonly] { background-color: grey; } input[readonly].WarningText { background-color: red; }
<input type="text" class="WarningText" readonly/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.