sass 继承 占位符 %placeholder

@extend

//SCSS
.btn {
border: 1px solid #ccc;
padding: 6px 10px;
font-size: 14px;
} .btn-primary {
background-color: #f36;
color: #fff;
@extend .btn;
} .btn-second {
background-color: orange;
color: #fff;
@extend .btn;
}

编译出来的css

//CSS
.btn, .btn-primary, .btn-second {
border: 1px solid #ccc;
padding: 6px 10px;
font-size: 14px;
} .btn-primary {
background-color: #f36;
color: #fff;
} .btn-second {
background-clor: orange;
color: #fff;
}

占位符,减少代码的重复

//SCSS
%mt5 {
margin-top: 5px;
}
%pt5{
padding-top: 5px;
} .btn {
@extend %mt5;
@extend %pt5;
} .block {
@extend %mt5; span {
@extend %pt5;
}
}

转为css

//CSS
.btn, .block {
margin-top: 5px;
} .btn, .block span {
padding-top: 5px;
}

sass 继承 占位符 %placeholder

上一篇:[Sass]混合宏


下一篇:Windbg里识别CRT堆