gpt4 book ai didi

没有嵌套的 CSS 最后一个 child ?

转载 作者:行者123 更新时间:2023-11-28 16:03:09 25 4
gpt4 key购买 nike

在不嵌套的情况下添加 class="very-last-child" 时,我需要选择任何内容的最后一个子项。

例如,这里我需要选择最后一个 div。仅此而已。

<body>
<div class="very-last-child">
<p>The first paragraph.</p>
<p>The second paragraph.</p>
<p>The third paragraph.</p>
<p>The fourth paragraph.</p>
<div class="select-me">
<p>The first paragraph.</p>
<p>The second paragraph.</p>
<p>The third paragraph.</p>
<p>The fourth paragraph.</p>
</div>
</div>
</body>

我确实在这些线路上做了一些尝试,但没有奏效。

div > :last-of-type {
padding-bottom: 50px;
}

p, div{
border: 2px solid black;
}

USE CASE: I need to add padding to the last element of my page wrapper, regardless of whatever it may be. And I am using SCSS.

最佳答案

由于您的类(class)名称,您想要实现的目标有点不清楚,但这就是我认为您想要的。

.very-last-child > :last-child {
padding-bottom: 50px;
}

这会在 select-me 类的底部提供 50px 的填充

关于没有嵌套的 CSS 最后一个 child ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54384429/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com