如何将文字字符串注入 scss @mixin
How to inject literal string into scss @mixin
考虑以下 scss 代码:
@mixin homeSlider(
$dim: 150px,
$h1: "h1 { font-size: 4em; margin-top: 0; }"
){
section {
margin-top: -$dim;
}
$h1;
}
@include homeSlider( $dim: 50px, $h1: "h1 { font-size: 3em; margin-top: 0; }" )
我需要知道如何实现我的目标
试试这个
@mixin homeSlider($dim, $h1-font-size){
section {
margin-top: -$dim;
h1 {
font-size: $h1-font-size;
margin-top: 0;
}
}
}
@include homeSlider(50px, 3em;) /* $dim = 50px - $h1-font-size = 3em; */
考虑以下 scss 代码:
@mixin homeSlider(
$dim: 150px,
$h1: "h1 { font-size: 4em; margin-top: 0; }"
){
section {
margin-top: -$dim;
}
$h1;
}
@include homeSlider( $dim: 50px, $h1: "h1 { font-size: 3em; margin-top: 0; }" )
我需要知道如何实现我的目标
试试这个
@mixin homeSlider($dim, $h1-font-size){
section {
margin-top: -$dim;
h1 {
font-size: $h1-font-size;
margin-top: 0;
}
}
}
@include homeSlider(50px, 3em;) /* $dim = 50px - $h1-font-size = 3em; */