Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sass 根据嵌套块内部的主体类重新定义SCSS嵌套选择器_Sass - Fatal编程技术网

Sass 根据嵌套块内部的主体类重新定义SCSS嵌套选择器

Sass 根据嵌套块内部的主体类重新定义SCSS嵌套选择器,sass,Sass,我有一个SCSS规则集,看起来有点像这样: .thing { div { // rules } } .thing div { // rules } .deactivated .thing div { // override for when it's in body.deactivated } .thing { div { // rules } } .deactiviated { .thing { div { // othe

我有一个SCSS规则集,看起来有点像这样:

.thing {
  div {
    // rules
  }
}
.thing div {
  // rules
}

.deactivated .thing div {
  // override for when it's in body.deactivated
}
.thing {
  div {
    // rules
  }
}

.deactiviated {
  .thing {
    div {
      // other rules
    }
  }
}
有时我想根据添加到
主体中的类重新设置
.thing div
元素的样式,因此在标准CSS中,我会这样做:

.thing {
  div {
    // rules
  }
}
.thing div {
  // rules
}

.deactivated .thing div {
  // override for when it's in body.deactivated
}
.thing {
  div {
    // rules
  }
}

.deactiviated {
  .thing {
    div {
      // other rules
    }
  }
}

是否有一种方法可以跳出嵌套以指示SCSS中的顶级封闭选择器?

否。如果要嵌套,请执行以下操作:

.thing {
  div {
    // rules
  }
}
.thing div {
  // rules
}

.deactivated .thing div {
  // override for when it's in body.deactivated
}
.thing {
  div {
    // rules
  }
}

.deactiviated {
  .thing {
    div {
      // other rules
    }
  }
}