结合 Sass mixin 和 CSS 类?

Eva*_*nss -2 css sass

我创建了一个具有相同样式的 Sass mixin 和一个 CSS 类,因此开发人员可以选择将该类添加到 HTML 中或将 mixin 与 Sass 一起应用。

@mixin link-style-1 {
    background: $red;
    padding:  .75em 45px .75em 5%;
}
.link-style-1 {
    background: $red;
    padding:  .75em 45px .75em 5%;
}
Run Code Online (Sandbox Code Playgroud)

有没有办法将这2合并为1?我知道我可以使用一个变量来填充两者,但是这样我的代码会变得更长并且更难以阅读。有更清洁的解决方案吗?

Sci*_*ter 5

为了保持 DRYness,你可以在类中包含 mixin:

@mixin link-style-1 {
    background: $red;
    padding:  .75em 45px .75em 5%;
}
.link-style-1 {
    @include link-style-1;
}
Run Code Online (Sandbox Code Playgroud)