如何修改sass中的根父选择器 [英] How to modify the root parent selector in sass

查看:48
本文介绍了如何修改sass中的根父选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何修改父选择器链的根元素?(使用 sass 3.3.x)类似......

How can I modify the root element of the parent selector chain? (using sass 3.3.x) Something like...

=prepend($prefix)
  @at-root .#{$prefix}#{&}   // note there is no dot (.) separating it
    @content

.foo
  .bar
    +prepend(baz)
      background: red    

然后返回

.baz.foo .bar {
  background: red;
}

或者甚至更好......以根元素(甚至第n个元素)为目标的显式方法?

or even better... an explicit way to target the root element (or even the nth element)?

推荐答案

=prepend($prefix)
  &.#{$prefix}
    @content

.foo
  +prepend("baz")
    .bar
      background: red

返回:

.foo.baz .bar {
  background: red;
}

在正确的轨道上?

这篇关于如何修改sass中的根父选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆