scss-@at-root

354 阅读1分钟

 @at-root 指令可以使一个或多个规则被限定输出在文档的根层级上,而不是被嵌套在其父选择器下。
不使用该指令,编译成css

.parent {
   color: red;
   .child {
       width: 100px;
       height: 100px;
   }
}
.parent {
    color: red; 
}
.parent .child {
    width: 100px;
    height: 100px; 
}

使用该指令,编译成css

 .parent {
    color: red;
    @at-root .child {
        width: 100px;
        height: 100px;
    }
}
.parent {
    color: red; 
}
.child {
    width: 100px;
    height: 100px; 
}

后续学习到其他到在补充