运行 ❯
获取您
自身
的网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> #frameDiv { width: 400px; height: 170px; margin: 20px; position: relative; border: solid black 1px; background-color: rgb(205, 242, 205); } img { width: 70px; offset-path: path('M 50 80 C 100 -100 200 220 350 150'); animation: moveImg 4s 1s 3; } svg { position: absolute; height: 100%; width: 100%; left: 0; top: 0; } @keyframes moveImg { 0% { offset: path('M 50 80 C 100 -100 200 220 350 150') 0% auto; } 100% { offset: path('M 50 80 C 150 80 250 80 350 80') 100% auto 180deg; } } </style> </head> <body> <h1>The offset property animated</h1> <div id="frameDiv"> <svg fill="none" stroke="gray" stroke-width="2" > <path d="M 50 80 C 100 -100 200 220 350 150" stroke-dasharray="5,5" /> <path d="M 50 80 C 150 80 250 80 350 80" /> </svg> <img src="img_fish.svg" alt="fish"> </div> <p>Here, the offset shorthand property is animated with a gradual change in offset-path, offset-distance and offset-rotate.</p> <p>The dashed line is the initial path, and the solid line is the path the fish transitions to at the end of the animation.</p> </body> </html>