CSS Selector quot;(A or B) and Cquot;?(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 的 or
运算符 (,
) 不允许分组.它本质上是选择器中优先级最低的逻辑运算符,因此您必须使用 .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"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:CSS 选择器“(A 或 B)和 C"?


- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 失败的 Canvas 360 jquery 插件 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06