【问题标题】:SVG filter is not working properly for straight line [duplicate]SVG过滤器不适用于直线[重复]
【发布时间】:2016-02-03 18:20:11
【问题描述】:
<svg height="210" width="500">
  <defs xmlns="http://www.w3.org/2000/svg">
    <filter id="dropshadow" height="130%">
      <feGaussianBlur in="SourceAlpha" stdDeviation="3" />
      <feOffset dx="2" dy="2" result="offsetblur" />
      <feMerge>
        <feMergeNode/>
        <feMergeNode in="SourceGraphic" />
      </feMerge>
    </filter>
  </defs>
  <line x1="0" y1="100" x2="200" y2="100" style="stroke:rgb(255,100,90);stroke-width:3px" filter="url(#dropshadow)" />
</svg>

我试图在直线上使用阴影,但它隐藏了线本身。如果我使用对角线,它可以正常工作。

【问题讨论】:

  • 与梯度问题相同,但用于过滤器而不是梯度。
  • 只需添加 filterUnits="userSpaceOnUse" 并将 height="15" 更改为您的过滤器元素

标签: svg svg-filters


【解决方案1】:

尝试更换零件并放入style="stroke:rgb(255,0,0);stroke-width:2"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-29
    • 1970-01-01
    • 2017-08-21
    • 2018-11-12
    • 2021-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多