Set a variable in Sass depending on the selector

前端 未结 8 1073
失恋的感觉
失恋的感觉 2020-12-10 10:20

I’ve got a website that’s using a few different ‘main’ colors. The general HTML layout stays the same, only the colors change depending on the content.

I was wonderi

8条回答
  •  有刺的猬
    2020-12-10 10:51

    You can also create a mixing that use the ampersand parent selector. http://codepen.io/juhov/pen/gbmbWJ

    @mixin color {
      body.blue & {
        background: blue;
      }
      body.yellow & {
        background: yellow;
      }
    }
    

提交回复
热议问题