带有渐变笔划的SVG线不会显示为直线 [英] SVG Line with Gradient Stroke Won't Display Straight
本文介绍了带有渐变笔划的SVG线不会显示为直线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用SVG复制<hr>
.现在,使用SVG绘制直线效果很好,但是第二次我用渐变对其进行描边将不再显示在直线上.
I'm attempting to replicate an <hr>
with SVG. Now, making a straight line with SVG works perfectly, but the second I stroke it with a gradient it will no longer display in a straight line.
以下代码有效,但请注意,y1和y2必须相隔1个单位.例如,如果我将y1和y2设置为210,该行将消失.
The following code works, but take note, y1 and y2 must be 1 unit apart. If I set y1 and y2 to 210 for instance, the line will disappear.
<defs>
<linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color:rgba(0,0,0,0);stop-opacity:0" />
<stop offset="50%" style="stop-color:rgba(0,0,0,0.75);stop-opacity:1" />
<stop offset="100%" style="stop-color:rgba(0,0,0,0);stop-opacity:0" />
</linearGradient>
</defs>
<line x1="40" y1="210" x2="460" y2="211" stroke="url(#grad1)" stroke-width="1" />
我可能只是缺少一些线性渐变的明显功能,而且线条看起来还不错,但我宁愿将其弄直.谢谢.
I'm probably just missing some obvious function of linear gradients, and the line looks alright, but I'd much rather just have it straight. Thanks.
推荐答案
查看全文