css - 关于 css 中的祖先选择器

标签 css css-selectors

<分区>


想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post .

关闭 7 年前

所以我已经阅读了很多关于 css 中的祖先选择器的主题,其中大部分都不知道是否有。现在我很清楚,到目前为止还没有祖先选择器。但是我很难理解为什么。显然它们可能非常有用,但由于某些原因,它们目前还不是 css 的一部分。有人能告诉我使用祖先选择器会导致什么问题,所以他们决定根本没有祖先选择器吗?

最佳答案

嗯,根据 CSS-Tricks ,

With parent selectors it becomes extremely easy to accidentally cause a document-wide grovel. People can and will misuse this selector. Supporting it is giving people a whole lot of rope to hang themselves with.

要考虑的事情是,

  • 存在巨大的性能问题
  • 可以将这些担忧视为我们应该评估的权衡,而不是阻碍。
  • 想要!

您还可以阅读 CSS 选择器 here 和 CSS 模式匹配 here

关于css - 关于 css 中的祖先选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36628729/

上一篇:php - 菜单中的效果

下一篇:html - CSS 三列布局,第一列未知,第二列灵活

相关文章:

html - 使用显示 : inline-block - unexpected space 将 div 设置为自动适应其内容

javascript - ui-sortable 不工作(对于预定义的 DOM 位置)

javascript - 如何将 jQuery 应用于 .element :before:hover?

html - CSS :not selector to target specific types of input

javascript - jQuery 可以通过 CSS 规则而不是类进行选择吗?

javascript - 页脚元素随视口(viewport)均匀扩展

javascript - 幻灯片 javascript 不工作

html - CSS 选择器选择 n 个元素后的第一个元素

Internet Explorer 8 中的 CSS 伪类

css - IE8 : what to use in place of nth-of-type(n)?