您应该根据输入的类型使用 CSS 类名称。例如,文本输入应该有一个 CSS 类名“TextBox”,检查输入应该有一个 CSS 类名“CheckBox”,您可以单独设置所有 css 属性。您还可以在单个元素上设置多个 CSS 类名称,例如"Control TextBox Disabled"
,"Control CheckBox"
或"Control Label Red-Text"
.
您也可以使用 JQuery 选择器并找到任何类型的输入并做任何您想做的事情。
我希望这有帮助:
.Control
{
display: block;
width: 94%;
color: #777;
font-family: Arial;
font-size: 13px;
}
.TextBox-Base
{
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
border: 1px solid #ADADAD;
outline: none;
margin: 5px 0;
padding: 8px;
}
.TextBox,
.PasswordBox
{
}
.RichTextBox
{
overflow: auto;
resize: none;
}
.DropDownList
{
}
HTML 示例代码:
<input type="text" class="Control TextBox-Base PasswordBox" />
<input type="password" class="Control TextBox-Base PasswordBox" />
<textarea class="Control TextBox-Base RichTextBox"></textarea>
<select class="Control DropDownList" ></select>
使用 JQuery 选择元素:
$(".TextBox-Base") //returns all the elements that has "TextBox-Base" class name included.
$(".TextBox") //returns all the elements that has "TextBox" class name included.
$(".PasswordBox") //returns all the elements that has "PasswordBox" class name included.
$(".RichTextBox") //returns all the elements that has "RichTextBox" class name included.
$(".DropDownList") //returns all the elements that has "DropDownList" class name included.
干杯