【问题标题】:Element stop is missing required attribute offset on SVG Linear Gradient FillSVG 线性渐变填充上的元素停止缺少必需的属性偏移
【发布时间】:2015-10-05 20:48:18
【问题描述】:

W3 验证抛出以下错误:-

Element stop is missing required attribute offset

关于此代码:-

<!--  Defining Angle Gradient Colors  -->
<svg width="0" height="0">
<defs>
<!-- Colours red #ca3b37 gold #f0a635 blue #4fc4f6 green #0FBD46-->
<linearGradient id="cl1" gradientUnits="objectBoundingBox" x1="0" y1="0" x2="1" y2="1">
<stop stop-color="#ca3b37"/>
<stop offset="100%" stop-color="#ca3b37"/>
</linearGradient>
<linearGradient id="cl2" gradientUnits="objectBoundingBox" x1="0" y1="0" x2="0" y2="1">
<stop stop-color="#ca3b37"/>
<stop offset="100%" stop-color="#f0a635"/>
</linearGradient>
<linearGradient id="cl3" gradientUnits="objectBoundingBox" x1="1" y1="0" x2="0" y2="1">
<stop stop-color="#f0a635"/>
<stop offset="100%" stop-color="#4fc4f6"/>
</linearGradient>
<linearGradient id="cl4" gradientUnits="objectBoundingBox" x1="1" y1="1" x2="0" y2="0">
<stop stop-color="#4fc4f6"/>
<stop offset="100%" stop-color="#4fc4f6"/>
</linearGradient>
<linearGradient id="cl5" gradientUnits="objectBoundingBox" x1="0" y1="1" x2="0" y2="0">
<stop stop-color="#4fc4f6"/>
<stop offset="100%" stop-color="#0FBD46"/>
</linearGradient>
<linearGradient id="cl6" gradientUnits="objectBoundingBox" x1="0" y1="1" x2="1" y2="0">
<stop stop-color="#0FBD46"/>
<stop offset="100%" stop-color="#0FBD46"/>
</linearGradient>
</defs>
</svg>

谁能告诉我缺少的属性是什么/如何应用它。

谢谢

格伦尼男孩

【问题讨论】:

    标签: svg gradient offset


    【解决方案1】:

    在您的示例中,有些停止元素具有偏移属性,有些则没有。您需要为所有没有的添加偏移属性。

    <stop stop-color="#ca3b37"/>
    <stop offset="100%" stop-color="#ca3b37"/>
    

    变成

    <stop offset="<some value you need to decide on>" stop-color="#ca3b37"/>
    <stop offset="100%" stop-color="#ca3b37"/>
    

    您将 替换为一个值,也许是 0。

    【讨论】:

    • 啊,明白了。在我的情况下,第一个偏移量需要是 offset="0%" ,但感谢您指出问题(现在非常明显:-)
    猜你喜欢
    • 2017-04-25
    • 2013-09-04
    • 2011-12-05
    • 2013-11-10
    • 1970-01-01
    • 2014-06-07
    • 2015-11-10
    • 1970-01-01
    相关资源
    最近更新 更多