html - SVG 直线动画 CSS

标签 html css svg svg-animate

我试图通过在网站中使用 SVG 路径动画来实现这一点(下图)。我看到这个 https://css-tricks.com/svg-line-animation-works/并想尝试一下。但我不确定如何创建路径和动画。请帮帮我!谢谢

enter image description here

最佳答案

您可以使用 svg 代码制作动画。您可以在 svg 路径上使用 CSS 动画。

.st0{
fill:none;
stroke:#000000;
stroke-miterlimit:10;
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
-webkit-animation: draw1 4s linear forwards;
animation: draw1 4s linear forwards;
}
.st1{
fill:none;
stroke:#000000;
stroke-miterlimit:10;
stroke-dasharray: 200;
stroke-dashoffset: 200;
-webkit-animation: draw2 3s linear 2s forwards;
animation: draw2 3s linear 2s forwards;
}
  
@-webkit-keyframes draw1{
  to {stroke-dashoffset: 0;}
}
@keyframes draw1{
  to {stroke-dashoffset: 0;}
}
@-webkit-keyframes draw2{
  to {stroke-dashoffset: 0;}
}
@keyframes draw2{
  to {stroke-dashoffset: 0;}
}
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
	 viewBox="0 0 614 53" style="enable-background:new 0 0 614 53;" xml:space="preserve">
<polyline class="st0" points="0.5,53 0.5,20.7 613.5,20.7 613.5,53 "/>
<line class="st1" x1="307" y1="53" x2="307" y2="0"/>
</svg>

关于html - SVG 直线动画 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47806331/

相关文章:

css - SVG animatetransform 旋转,不能在 ie 和 firefox 上完美运行

JQuery Draggable 和带有 SVG 的 <object>?

css - 使用 CSS 调整不同大小的图像

html - 忽略 iframe 中的指针事件

javascript - Jquery: $.each() 返回值然后结束

html - 设置div动态填充其余高度?

html - 部分背景在手机上被截掉

xml - VBA XML 选择命名空间问题

jquery - 如何控制jQuery slideToggle下推的div

javascript - 居中对齐两个div与右边的图像