【发布时间】:2020-09-15 21:26:57
【问题描述】:
在 CSS 中,是否可以递归选择所有 :last-child from body?
鉴于此标记:
<body>
<div id="_1">
<div id="_2"></div>
</div>
<div id="_3">
<div id="_4">
<div id="_5"></div>
<div id="_6"></div>
</div>
</div>
</body>
我正在寻找 div 号。 3、4、6
另一种说法是:
body > :last-child,
body > :last-child > :last-child,
body > :last-child > :last-child > :last-child,
body > :last-child > :last-child > :last-child > :last-child {
/* My stuff here */
}
但显然这不是一个好方法。
【问题讨论】:
-
如果解决了以下问题之一,我们也可以解决这个问题:stackoverflow.com/questions/10227375/… | stackoverflow.com/questions/1014861/… 通过检查没有非最后一个父级。
标签: css css-selectors