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"?
基础教程推荐
- Bokeh Div文本对齐 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
