具有透明背景的 SVG 蒙版线动画

问题描述

我正在尝试使用 SVG 遮罩技术突出显示 HTML5 中的一个词。

这是我用来在 SVG 路径上实现动画的 CSS 代码

  @keyframes dash {
    from {
      stroke-dashoffset: 530;    
    }
    to {
      stroke-dashoffset: 0;    
    }
  } 

  .shape path {
    stroke-dasharray: 530;
    stroke-dashoffset: 0;  
    fill: white;
    opacity: 0;
  }

  .shape.active path {
    opacity: 1;
    animation: dash .5s ease-in forwards;
  }

总的来说,它运作良好。但是,它在播放动画时显示白色填充背景:

enter image description here

我怎样才能使它透明,以便它可以在任何背景颜色上工作?

这里是代码链接,您可以在其中查看动画:https://codepen.io/willhalling/pen/QWpXpQa

已编辑:我已更新 codepen 链接以包含 @enxaneta 解决方

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)