我正在使用Bootstrap 5&;SCSS来定义我的css.我知道我可以在html中包含p-2
作为填充.但我如何才能在SCSS本身中引用该填充呢?我不想超越任何事情,我只想能够做,比如说:
.x {
color: $gray2;
padding: //one that is same for p-2 - whatever it is
}
我不想给那个填充精确的px值,因为这可能会改变.
我正在使用Bootstrap 5&;SCSS来定义我的css.我知道我可以在html中包含p-2
作为填充.但我如何才能在SCSS本身中引用该填充呢?我不想超越任何事情,我只想能够做,比如说:
.x {
color: $gray2;
padding: //one that is same for p-2 - whatever it is
}
我不想给那个填充精确的px值,因为这可能会改变.
您最有可能是在寻找extend
号房产.
假设p-2看起来像这样.
.p-2 {
padding: 2rem;
}
然后在您的类上使用EXTEND
.x {
@extend .p-2;
color: $gray2;
}
会在最终的css中给出这一点.
.x {
padding: 2rem;
color: $gray2;
}