代码之家  ›  专栏  ›  技术社区  ›  Noldorin

在HTML文档中嵌入SVG过滤器

  •  0
  • Noldorin  · 技术社区  · 7 年前

    有没有办法嵌入SVG filter svg 元素本身嵌入到HTML文档中 元素本身占用空间,这是不需要的。

    0 回复  |  直到 7 年前
        1
  •  3
  •   Alexandr_TT    7 年前

    您可以这样尝试:

    • 包装 svg div
    • 为了 部门 ,指定css属性 position: absolute; 哪个会 标记
    • 隐藏
    • CSS ,按其 id 任何其他HTML标记对象

      filter:url(#nameID);

    更新:

    我必须提到使用 display: none;

    question 详细讨论了SVG滤波器在各种浏览器中的应用问题。

    @保罗·勒博 answer 建议使用SVG width = "0" height = "0" 而不是

    下面是他的答案的密码。

    <video autoplay controls muted src=" https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" style="width: 488px; height: 360px; filter: url(#temperature_filter)">
    </video>
    
    <svg xmlns="http://www.w3.org/2000/svg" width="0" height="0">
      <filter id="temperature_filter" color-interpolation-filters="sRGB">
        <feColorMatrix type="matrix" values="1 0 0 0 0 0 0.694 0 0 0 0 0 0.431 0 0 0 0 0 1 0"></feColorMatrix>
      </filter>
    </svg>

    如评论中所述,@enxaneta最好使用:

    svg{position: absolute; width: 0; height: 0;}