需要CSS列表/选择与现有输入/ textarea相同

时间:2012-09-11 11:48:32

标签: css

我的表单中有这些css,但下拉列表/选择缺少css。我需要与以下相同的格式:

CSS:

form input[type="password"], form input[type="text"] {
display: block;
width: 94%;
margin: 5px 0;
padding: 8px;
color: #777;
font-family: Arial;
font-size: 13px;

-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;

border: 1px solid #ADADAD;
outline: none;
}

form textarea {
display: block;
width: 94%;
margin: 5px 0;
padding: 8px;
color: #777;
font-family: Arial;
font-size: 13px;
overflow: auto;
resize: none;

-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;

border: 1px solid #ADADAD;
outline: none;
}

2 个答案:

答案 0 :(得分:1)

您应该根据输入的类型使用CSS类名。例如,文本输入应该具有CSS类名“TextBox”,并且检查输入应该具有CSS类名“CheckBox”,并且可以分别设置所有css属性。您还可以在"Control TextBox Disabled""Control CheckBox""Control Label Red-Text"等单个元素上设置多个CSS类名称。

此外,您可以使用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.

干杯

答案 1 :(得分:0)

您可以使用选择选择器

form select {

}