1、虚线:
.line1{
stroke: black;
stroke-width: 10px;
stroke-dasharray: 10px 10px; /* 虚线 */
stroke-dashoffset:10px ;/* 虚线偏移:向左偏移 */
animation: move 2s linear infinite alternate-reverse;
}
2、伸缩条动画:
<style>
.line1{
stroke: black;
stroke-width: 10px;
stroke-dasharray: 200px;
stroke-dashoffset: 200px;
animation: move 2s linear infinite alternate-reverse;
}
@keyframes move {
0%{
stroke-dashoffset: 200px;
}
100%{
stroke-dashoffset: 0px;
}
}
</style>
</head>
<body>
<svg width="500px" height="300px" style="border: 1px solid">
<line x1="100" y1="100" x2="300" y2="100" class="line1"></line>
</svg>
</body>