在 CSS 中是否有一个选择器用于引用也有一个类的特定输入类型?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14243088/
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
In CSS is there a selector for referencing a specific input type that also has a class?
提问by Art Geigel
Basically I want a CSS selector that grabs all input[type="text"] but that also has a class "some-class".
基本上我想要一个 CSS 选择器来获取所有输入 [type="text"] 但它也有一个类“some-class”。
Both of the following don't seem to be working for me:
以下两项似乎都不适合我:
input[type="text"] .some-class {} /* doesn't work */
.some-class input[type="text"] {} /* doesn't work */
I'm sure I'm missing something simple here. Thanks in advance.
我确定我在这里遗漏了一些简单的东西。提前致谢。
回答by wless1
You want input.some-class[type="text"]
你要 input.some-class[type="text"]
.some-class input
looks for input tags that are descendants of .some-class
.
.some-class input
查找是 的后代的输入标签.some-class
。
input.some-class
does the reverse.
input.some-class
反之。
回答by Hasteq
input[type="text"].some-class {
....
}
with no space between "input[type="text"]" and ".some-class" will work..
"input[type="text"]" 和 ".some-class" 之间没有空格会起作用..
input[type="text"]-space in between is the problem-.some-class {}
input[type="text"]-中间的空格是问题-.some-class {}