在SASS中是否有任何方法可以在其选择器中嵌套标签?

时间:2017-06-08 16:48:35

标签: css sass

以下是我的代码:

.page-header {
    font-family: 'Roboto', sans-serif;
    color: #333;
}

现在我想根据标签(h1,h2,h3等)设置标题的字体大小。以下是我目前所做的事情:

h1.page-header {
    font-size: 56px;
}
h2.page-header {
   font-size: 38px;
}

有没有办法将它嵌套起来:

.page-header {
    color: #333;

    h1 {
        font-size: 56px;
    }
}

(我知道这不会像我期望的那样工作,只是为了让你知道我想要的东西。)

1 个答案:

答案 0 :(得分:2)

使用&@at-root使用&#{} &来引用当前选择器。

ab <- merge(effect, expression, by.x = "V3", by.y = "V1")
cd <- subset(ab, V2.x == "activates" & V2.y == 1 | V2.x == "stops" & V2.y == 0)
results <- cd[,c(2,3,1)]
> results
  V1      V2.x V3
2 G3     stops G4
3 G5 activates G6

将产生:

.page-header {
  @at-root h1#{&} {
    font-size: 56px;
  }
  @at-root h2#{&} {
    font-size: 38px;
  }
}