运行 ❯
获取您的
自己的
网站
×
更改方向
保存代码
更改主题,暗/亮
前往 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 { position: absolute; z-index: 1; width: 70px; offset: path('M 50 80 C 150 -20 250 180 350 80') 150px -90deg / 0% 50%; animation: moveImg 4s 1s 3; } svg { position: absolute; height: 100%; width: 100%; left: 0; top: 0; } @keyframes moveImg { 100% { offset-distance: 100%; } } </style> </head> <body> <h1>The offset property</h1> <div id="frameDiv"> <img src="img_fish.svg" alt="fish"> <svg fill="none" stroke="gray" stroke-width="2" stroke-dasharray="5,5"> <path d="M 50 80 C 150 -20 250 180 350 80" /> </svg> </div> <p>Here, the shorthand property 'offset' is used to set property values for offset-path, offset-distance, offset-rotate and offset-anchor:</p> <ol> <li>The path for the animation is set (offset-path)</li> <li>the fish starts moving at a 150 pixels distance from the start of the path (offset-distance)</li> <li>the fish is rotated a constant -90 degrees (offset-rotate)</li> <li>the fish is connected to the path at the end of its tail, at the very left side of the element, 50% from the top (offset-anchor)</li> </ol> </body> </html>