213

Sass または SCSS の構文に従って、:before および :after 疑似要素セレクターを使用するにはどうすればよいですか? このような:

p
  margin: 2em auto
  > a
    color: red
  :before
    content: ""
  :after
    content: "* * *"

もちろん、上記は失敗します。

4

1 に答える 1

482

アンパサンドを使用して、親セレクターを指定します

SCSS 構文:

p {
    margin: 2em auto;

    > a {
        color: red;
    }

    &:before {
        content: "";
    }

    &:after {
        content: "* * *";
    }
}
于 2012-05-25T08:06:36.523 に答える