<!DOCTYPE html>
<html>
<head>
<style>
#frameDiv {
width: 400px;
height: 350px;
margin: 20px;
position: relative;
border: solid black 1px;
background-color: rgb(205, 242, 205);
}
img {
position: absolute;
z-index: 1;
width: 70px;
animation: moveImg 5s 3;
}
svg {
position: absolute;
height: 100%;
width: 100%;
left: 0;
top: 0;
}
#fish1 {
offset-path: path('M 50 80 C 150 -20 250 180 350 80');
offset-rotate: auto;
}
#fish2 {
offset-path: path('M 50 180 C 150 80 250 280 350 180');
offset-rotate: auto 90deg;
}
#fish3 {
offset-path: path('M 50 280 C 150 180 250 380 350 280');
offset-rotate: 90deg;
}
@keyframes moveImg {
100% { offset-distance: 100%; }
}
</style>
</head>
<body>
<h1>offset-rotate 属性</h1>
<div id="frameDiv">
<img id="fish1" src="/i/css/fish.svg" alt="鱼">
<img id="fish2" src="/i/css/fish.svg" alt="鱼">
<img id="fish3" src="/i/css/fish.svg" alt="鱼">
<svg fill="none" stroke="gray" stroke-width="2" stroke-dasharray="5,5">
<path d="M 50 80 C 150 -20 250 180 350 80" />
<path d="M 50 180 C 150 80 250 280 350 180" />
<path d="M 50 280 C 150 180 250 380 350 280" />
</svg>
</div>
<p><b>第一条鱼</b> 的旋转方向与其移动方向一致。这是默认行为。</p>
<p><b>第二条鱼</b> 的旋转方向比其移动方向顺时针多 90 度。</p>
<p><b>第三条鱼</b> 始终向下旋转 90 度。</p>
</body>
</html>