如何在此过渡中添加背景图像以填充文本?

时间:2019-12-30 06:13:52

标签: html css animation svg

我在CSS中使用svg模式来创建文本动画。文本完成后,我希望将其填充为背景图像,而不是绿色。我怎么做?

em
body{
  background-color: #ECEAEA;
}

.text-line text {
  stroke-dasharray: 500;
  stroke-dashoffset: 500;
  animation: dash 5s linear forwards, filling 4s ease-in forwards;
}

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

@keyframes filling {
  from{
    fill: #F3F3F3;
    fill-opacity: 0;
  }
  to {
    fill: #1985A1;
    fill-opacity: 1;
  }
}

1 个答案:

答案 0 :(得分:1)

我可以通过将背景变成图案来实现。

尝试一下:

echo '<img src="specialRoot/'.$row->image_name.'" width="250">';
body{
  background-color: #ECEAEA;
}

.text-line text {
  stroke-dasharray: 500;
  stroke-dashoffset: 500;
  animation: dash 5s linear forwards, filling 6s ease-in forwards;
}

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

@keyframes filling {
  from{
    /*fill: #F3F3F3;*/
    fill-opacity: 0;
  }
  50% {
    fill-opacity: 0.1;
  }
  to {
    /*fill: #1985A1;*/
    fill-opacity: 1;
  }
}

相关问题