- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
"(大于号)CSS 选择器是什么意思?-6ren"> "(大于号)CSS 选择器是什么意思?-例如: div > p.some_class { /* Some declarations */ } > 符号到底是什么意思? 最佳答案 > 是 child combinator ,有时被错误地称-6ren">
例如:
div > p.some_class {
/* Some declarations */
}
>
符号到底是什么意思?
最佳答案
>
是 child combinator ,有时被错误地称为直接后代组合子。1
这意味着选择器 div > p.some_class
只匹配 .some_class
中直接嵌套在 div< 中的段落
,而不是嵌套在其中的任何段落。这意味着匹配 div > p.some_class
的每个元素也必然匹配 div p.some_class
,descendant combinator (空间),所以这两者经常被混淆是可以理解的。
比较子组合器和后代组合器的图示:
div > p.some_class {
background: yellow;
}
div p.some_class {
color: red;
}
<div>
<p class="some_class">Some text here</p> <!-- [1] div > p.some_class, div p.some_class -->
<blockquote>
<p class="some_class">More text here</p> <!-- [2] div p.some_class -->
</blockquote>
</div>
哪些元素与哪些选择器匹配?
同时匹配 div > p.some_class
和 div p.some_class
此 p.some_class
直接位于 div
内部,因此在两个元素之间建立了父子关系。由于“child”是一种“后代”,因此根据定义,任何子元素也是后代。因此,这两个规则都适用。
只匹配div p.some_class
此 p.some_class
包含在 div
中的 blockquote
中,而不是 div
本身。尽管此 p.some_class
是 div
的后代,但它不是子代;这是一个孙子。因此,仅应用其选择器中具有后代组合子的规则。
1 许多人更进一步称它为“直接子元素”或“直接子元素”,但这完全没有必要(而且对我来说非常烦人),因为子元素 反正根据定义是直接的,所以它们的意思完全一样。没有所谓的“间接 child ”。
关于css - ">"(大于号)CSS 选择器是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57338211/
例如: div > p.some_class { /* Some declarations */ } > 符号到底是什么意思? 最佳答案 > 是 child combinator ,有时被错误地称
例如: div > p.some_class { /* Some declarations */ } > 符号到底是什么意思? 最佳答案 > 是 child combinator ,有时被错误地称
例如: div > p.some_class { /* Some declarations */ } > 符号到底是什么意思? 最佳答案 > 是 child combinator ,有时被错误地称
例如: div > p.some_class { /* Some declarations */ } > 符号到底是什么意思? 最佳答案 > 是 child combinator ,有时被错误地称
我在一个项目中遇到了一段代码,看起来有点可怕。它应该显示两个数字之间的 +/- 增量,但它使用 > 来比较数字字符串而不是数字。 我假设代码目前按预期工作,所以我只是想了解 Ruby 在这种情况下如何
(case [dbo].[YearsInService]([DateEngaged],getdate()) when (0) then (0) when (1) then (4) w
我在 Netsuite 中有地址数据,如下所示,请注意,其中包含“”,然后与其他需要转义的字符一起签名才能成为 XML 文档中的有效字符。12 企业研发单元 3 & 4 "6"'7' 在 javas
我目前正在尝试使用 Sequence.js,它到目前为止非常棒。不过,有一条线我很难解释。是这样的: #sequence .seq-canvas > * {...} 我发现 > 表示给定类的所有直接
我是一名优秀的程序员,十分优秀!