如何修改sass中的根父选择器

时间:2014-04-22 21:20:13

标签: sass

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

=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个元素)?

1 个答案:

答案 0 :(得分:0)

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

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

返回:

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

在正确的轨道上?

相关问题