Sass 抽象超类

Sass 抽象超类,sass,Sass,我试图让SASS在编程中做一些类似于抽象超类的事情。我已经到了超类部分 .box { @include span-columns(1); @include border-radius(5px); height: 360px; overflow: hidden; } article { @extend .box; } figure { @extend .box; } 这是一种定义框的通用性的方法,而不会像mixin那样在生成的CSS中重复它们。然而,这个解决方案有一

我试图让SASS在编程中做一些类似于抽象超类的事情。我已经到了超类部分

.box {
  @include span-columns(1);
  @include border-radius(5px);
  height: 360px;
  overflow: hidden;
}


article {
  @extend .box;
}

figure {
  @extend .box;
}
这是一种定义框的通用性的方法,而不会像mixin那样在生成的CSS中重复它们。然而,这个解决方案有一个缺陷,就是为我并不真正需要和想要的(CSS)类“box”定义一个规则

当然,这是一个小问题,但我想知道是否有办法将“.box”添加到一个标签中,该标签仅在SASS预处理期间使用,不会出现在CSS中。

您想使用
%
而不是
来定义“超类”

%box {
  @include span-columns(1);
  @include border-radius(5px);
  height: 360px;
  overflow: hidden;
}

article {
  @extend %box;
}

figure {
  @extend %box;
}
请注意,这需要版本3.2+

您想要使用
%
而不是
定义“超类”

%box {
  @include span-columns(1);
  @include border-radius(5px);
  height: 360px;
  overflow: hidden;
}

article {
  @extend %box;
}

figure {
  @extend %box;
}

请注意,这需要版本3.2+

谢谢,这正是我想要的。谢谢,这正是我想要的。