【发布时间】:2017-09-05 12:07:53
【问题描述】:
我在 color.less 中有两个颜色变量
@color-example-1: red;
@color-example-2: yellow;
example.html 中的 svg 看起来像这样:
<svg viewBox="0 0 48 48">
<style type="text/css">
.st0{fill:url(#SVGID_1_);}
</style>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="0" y1="24" x2="48" y2="24">
<stop offset="0" style="stop-color:#FFF33B"/>
<stop offset="1" style="stop-color:#E93E3A"/>
</linearGradient>
<circle class="st0" cx="24" cy="24" r="24"/>
</svg>
是否可以用 @variable 替换停止颜色值,或者(甚至更好)在 css 文件中定义整个 linearGradient?
期望的结果是这样的:
css
.example-gradient {
background: linear-gradient(135deg, @color-example-1 0%,@color-example-2 100%);
}
html
<svg viewBox="0 0 48 48">
<circle class="example-gradient" cx="24" cy="24" r="24"/>
</svg>
【问题讨论】:
标签: css svg less gradient linear-gradients