【发布时间】:2021-11-17 13:06:44
【问题描述】:
我尝试在嵌套样式中使用 :last-child 伪类,但它不适用于 postcss
当然,我已将postcss 和postcss-nested 添加到我的项目中
/* without nesting it works */
.container {
outline: 2px dashed red;
height: 100%;
width: 100%;
display: flex;
}
.container .child {
font-size: 2rem;
margin-right: 1rem;
color: red;
}
.container .child::after {
content: '*';
}
.container .child:not(:last-child) {
color: blue;
}
/*
But with nesting it won't work
.container {
outline: 2px dashed red;
height: 500px;
width: 1000px;
display: flex;
& > .child {
font-size: 2rem;
color: red;
&::after {
content: '*';
}
&:not(:last-child) {
color: blue;
}
}
}
*/
<div class="container">
<div class="child">first</div>
<div class="child">second</div>
<div class="child">third</div>
<div class="child">last-child</div>
</div>
【问题讨论】:
标签: css pseudo-class postcss