css - 在这种情况下,有没有更好的方法来使用嵌套的 SASS 和选择器?
问题描述
我需要选择一个元素的子元素,但它基于父元素的 :last-of-type 。
我试过了:
&:last-of-type {
&__content {
border-bottom: 0;
}
}
由于 SASS 的构造方式,这不起作用。
我最终得到:
.assignment-selection {
&__list-item {
&__content {
border-bottom: 1px solid;
}
&:last-of-type {
.assignment-selection {
&__list-item {
&__content {
border-bottom: 0;
}
}
}
}
}
}
有没有更好/更有效的方法来写这个?
解决方案
这应该这样做
&:last-of-type > &__content {
border-bottom: 0;
}
推荐阅读
- vuejs3 - vue 3 async setup() 模板段在异步时似乎没有加载
- python - Plotly 密度热图使更平滑或更不条纹?
- c# - 路由 ASP.NET Core 的问题
- laravel - 使用 Laravel 8 将文件上传到 Firebase 存储时减小了文件大小
- jenkins - 尝试从任何 Jenkins JMeter 作业配置中保存任何内容时出错
- android - 房间数据库在添加新表和更新版本号后挂起
- python-3.x - ImportError:无法从“fsspec.asyn”导入名称“maybe_sync”
- javascript - 无法在 mongoDB 中创建唯一索引
- c# - 无法在 COSMOS 内核上使用 C# 将文件保存到目录
- c++ - 使用 Visual Studio 从 .net .dll 文件创建 .lib 文件