Html 选择列表的 CSS 样式输入 [type="??"]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9904653/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CSS styling input [type="??"] for select lists
提问by Nick
Possible Duplicate:
CSS Select Selector
可能的重复:
CSS 选择选择器
What is the CSS equivalent to the following when dealing with select lists?
处理选择列表时,CSS 等效于以下内容?
input[type="text"]
input[type="submit"]
回答by Matt
The input[type="text"]
CSS selector can be broken down into;
该input[type="text"]
CSS选择器可以被分解成;
input
; find all elements that areinput
elements.[type="text"]
; filter those elements by those which have thetype
attribute oftext
.
input
; 找到所有属于input
元素的元素。[type="text"]
; 通过具有type
属性的元素过滤这些元素text
。
Because a select box is a <select>
element rather than a <input type="select" />
, you can just use the select
selector as follows;
因为选择框是一个<select>
元素而不是 a <input type="select" />
,所以你可以select
像下面这样使用选择器;
select {
/* blah blah blah*/
}
回答by Fabrizio Calderan
select is not a type of input like those in your example, so you cannot use an attribute selector when you target a select
select 与您的示例中的输入类型不同,因此当您定位一个时,您不能使用属性选择器 select
回答by patad
select {
border:1px solid green;
}
select option {
font-weight:bold;
}
回答by Stéphane
As Fabrizio-Calderan says, select does not have a type property. however, you could use the data-property and style your element based on this
正如 Fabrizio-Calderan 所说, select 没有 type 属性。但是,您可以使用数据属性并基于此设置元素样式
see here : Select elements by data attribute in CSS
请参见此处:通过 CSS 中的数据属性选择元素
Why not using a class to style it?
为什么不使用一个类来设计它?
Pseudo code:
伪代码:
<select>
<option class="wise">
<option class="not-so-wise">
<option class="meh">
</select>