CSS没有嵌套的最后一个子对象?
当我添加class=最后一个没有嵌套的子对象时,我需要选择任何对象的最后一个子对象 例如,在这里我需要选择最后一个divCSS没有嵌套的最后一个子对象?,css,sass,Css,Sass,当我添加class=最后一个没有嵌套的子对象时,我需要选择任何对象的最后一个子对象 例如,在这里我需要选择最后一个div <body> <div class="very-last-child"> <p>The first paragraph.</p> <p>The second paragraph.</p> <p>The third paragraph.</p> <p>T
<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>
用例:我需要向页面包装器的最后一个元素添加填充,不管它是什么。我正在使用SCSS
由于您的类名,您试图实现什么目标有点不清楚,但以下是我认为您想要的
.very-last-child > :last-child {
padding-bottom: 50px;
}
这将在类select me的底部提供50px的填充。要仅选择容器的最后一个子级,可以使用:
<selector> > :last-child {
...
}
你试过身体吗?>:最后一个孩子?我试过了。继续,用sass的解决方案重播。我已经添加了一个答案。请标记为正确,以帮助任何有类似问题的人
<selector> > :last-child {
...
}
body > :last-child {
...
}