CSS选择器“(A或B)和C” [英] CSS Selector "(A or B) and C"?
本文介绍了CSS选择器“(A或B)和C”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这应该很简单,但我无法找到它的搜索字词。
让我们说我有这个:
This should be simple, but I'm having trouble finding the search terms for it.
Let's say I have this:
<div class="a c">Foo</div>
<div class="b c">Bar</div>
在CSS中,如何创建一个匹配匹配(.a或.b )和.c?
In CSS, how can I create a selector that matches something that matches "(.a or .b) and .c"?
我知道我可以这样做:
.a.c,.b.c {
/* CSS stuff */
}
但是,假设我要做很多逻辑,用各种逻辑组合,有更好的语法吗?
But, assuming I'm going to have to do this sort of logic a lot, with a variety of logical combinations, is there a better syntax?
推荐答案
有更好的语法吗?
is there a better syntax?
CSS'或
运算符(,
)不允许分组。它本质上是选择器中最低优先级的逻辑运算符,因此必须使用 .a.c,.b.c
。
No. CSS' or
operator (,
) does not permit groupings. It's essentially the lowest-precedence logical operator in selectors, so you must use .a.c,.b.c
.
这篇关于CSS选择器“(A或B)和C”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文