我如何使用:before和:after伪元素选择器遵循Sass或SCSS的语法?是这样的:

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

当然,上述说法并不成立。


当前回答

使用&号来指定父选择器。

SCSS语法:

p {
    margin: 2em auto;

    > a {
        color: red;
    }

    &:before {
        content: "";
    }

    &:after {
        content: "* * *";
    }
}

其他回答

使用&号来指定父选择器。

SCSS语法:

p {
    margin: 2em auto;

    > a {
        color: red;
    }

    &:before {
        content: "";
    }

    &:after {
        content: "* * *";
    }
}