来源:3-2 SVG-线性渐变和径向渐变

洪炉百炼生

2014-10-06 20:44

<svg xmlns="http://www.w3.org/2000/svg">
    <defs>
        <linearGradient id="grad1" gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="1" y2="1">
            <stop offset="0" stop-color="#1497FC"></stop>
            <stop offset="0.5" stop-color="#001122"></stop>
            <stop offset="1" stop-color="#ABCDEF"></stop>
        </linearGradient>
    </defs>
    <rect x="100" y="100" fill="url(#grad1)" ></rect>
</svg>

<!-- 线性渐变 -->

写回答 关注

1回答

  • qq_唯愛沵_03419990
    2016-08-26 16:57:09

    我觉得你的代码有问题

    1 你没有设置viewBox

    2 你没有设置矩形的高宽。

走进SVG

SVG是HTML5 中矢量图的标记语言,学习后掌握更多的干货

52716 学习 · 223 问题

查看课程

相似问题