用&符号(SCSS)定位直接父母

时间:2015-07-15 19:37:24

标签: sass

我正在体验我认为scss中的奇怪行为。

我有一个嵌套2级深度的课程,我尝试使用&符号来定位直接父级,但是它会定位到父级的父级。

.one {
      .two{
        .three & {
          background:red;
          //should be .one .three .two right?
          //instead targets .three .one .two
        }
      }
    }

以下是codepen http://codepen.io/gpspake/pen/KpeEXp

上此行为的示例

1 个答案:

答案 0 :(得分:1)

根据Referencing Parent Selectors: &

,这是预期的行为

我不建议使用这种技术,因为它反直觉。

相关问题