css - How can I nest a selector with ::after psudo class using SCSS?
问题描述
I have a selector with ::after pseudo class. When I'm nesting it the result is wrong!
This is my SCSS:
#room .message::after {
content: "";
position: absolute;
left: -8px;
&.owner {
left: 4px;;
}
}
And the compiled CSS:
#room .message::after {
content: "";
position: absolute;
left: -8px;
}
/* This is wrong*/
#room .message::after.owner {
left: 4px;
}
But this is what I want:
#room .message::after {
content: "";
position: absolute;
left: -8px;
}
#room .message.owner::after{
left: 4px;
}
解决方案
the & give you all string of your previous selection.
#room .message::after and #room .message.owner::after are two different part. use this
#room .message {
&::after {
content: "";
position: absolute;
left: -8px;
}
&.owner::after {
left: 4px;
}
}
推荐阅读
- python - 如何在 matplotlib 中复制 gnuplot 的伪 3D 图,以便随时间分配蛋白质的二级结构?
- python - 如何使用 pandas DataFrame 在列轴连接中使用 join_axes?
- php - 如何使用 laravel 5.4 制作工作菜单选项卡
- django - 如何在 Django Rest Framework 中注册后自动生成电子邮件?
- php - 从商店页面 woocommerce 添加到购物车分组产品
- x86-64 - 将 x86-64 上的 long double 传递给可变参数函数
- r - 从数据帧转换为 sf
- javascript - 我想制作包含 css 和 javascript * .html、* .js 和 * .css 的单独 html 文件
- python - Nuke OFX 插件 - 自定义图标
- wordpress - 在 wordpress 仪表板中提交表单后显示成功消息