CSS“和”选择器 - 我可以选择具有多个类的元素吗? [英] CSS "and" selector - Can I select elements that have multiple classes?
问题描述
我试图选择所有同时具有 .checked
和 .featured
标签的元素。所以基本上,我要找的是一个和选择器;我不知道是否有一个。
有没有解决这种情况的解决方法?
您使用两个(之间没有空格)
.checked.featured {
// ...
}
参考: http://www.w3.org/TR/ 示例 I'm trying to select all of the elements that have both Is there any workaround for cases like this? You use both (without space between them) Reference: http://www.w3.org/TR/selectors/#class-html Example
这篇关于CSS“和”选择器 - 我可以选择具有多个类的元素吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
$ b
div {margin:1em; padding:1em;}。checked {color:green;}。featured {border:1px solid #ddd ;}。checked.featured {font-weight:bold; }
< div class =checked> element with checked class< / div>< div class =featured>元素与精选类< / div>< div class =featured checked>元素与精选类和精选类< / div>
.checked
and .featured
tags. So basically, what I'm looking for is an "and" selector; I don't know if there is one or not..checked.featured{
// ...
}
div{margin:1em;padding:1em;}
.checked{color:green;}
.featured{border:1px solid #ddd;}
.checked.featured{
font-weight:bold;
}
<div class="checked">element with checked class</div>
<div class="featured">element with featured class</div>
<div class="featured checked">element with both checked and featured classes</div>