我在这里引用了另一个主题,但无济于事。
本质上我试图应用按钮一半长度的文本阴影,我以前使用静态值工作,但想更改它以动态调整按钮的大小,可以选择将阴影放在左侧/图标的右侧。
$size: 80px;
$color-primary: ######;
@mixin shadow($clr: $color-primary, $perc: 15%, $dir: 'right') {
$all: ();
@for $i from 1 through strip-units($size/2) {
$shadow: "#{$i}px #{$i}px darken($clr, unquote($perc))";
@if $dir == 'left'{
$all: append($all, append(unquote(-$shadow), comma))
} @else {
$all: append($all, append(unquote($shadow), comma))
}
}
text-shadow: $all;
}
button {
background-color: $color-primary;
color: $color-secondary;
display: inline-block;
font-size: ($size/1.5);
vertical-align:middle;
width: $size;
height: $size;
line-height: ($size + 4px)
@include shadow($color-primary);
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮我让这个 mixin 工作吗?我觉得我很接近。
编辑:
抱歉,我应该澄清一下;似乎根本没有弹出任何错误,它只是不生成阴影。
调用 mixin 时的 …
sass ×1