效果图:
用到的CSS属性:
额外的属性:
MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/offset-rotate
假设设置了: offset-rotate: 45deg;
完整代码:
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Documenttitle>
<style>
.box {
width: 5px;
height: 5px;
background: red;
offset-path: path("M10,10 L20,50 L40,10 L60,50 L70,10");
animation: move 3s linear infinite;
offset-rotate: 45deg;
}
@keyframes move {
100% {
offset-distance: 100%;
}
}
style>
head>
<body>
<div class="box">div>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<path d="M10,10 L20,50 L40,10 L60,50 L70,10" stroke="green" stroke-width="1" fill="none" />
svg>
body>
html>