运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> #frameDiv { width: 430px; height: 180px; margin: 20px; position: relative; border: solid black 1px; background-color: rgb(205, 242, 205); } #circleDiv { border: solid darkred 3px; height: 10px; width: 10px; border-radius: 50%; position: absolute; z-index: 2; box-sizing: border-box; offset-path: path('M 50 80 L 350 80'); animation: moveCirc 5s 3; } #pinkDiv { position: absolute; width: 70px; height: 70px; background-color: hotpink; opacity: 0.5; z-index: 1; offset-path: path('M 50 80 L 350 80'); offset-anchor: bottom left; animation: movePink 5s 3; overflow: visible; } svg { position: absolute; height: 100%; width: 100%; left: 0; top: 0; } @keyframes movePink { 0% { offset-distance: 0%; offset-anchor: bottom left; } 100% { offset-distance: 100%; offset-anchor: top left; } } @keyframes moveCirc { 100% { offset-distance: 100%; } } </style> </head> <body> <h1>The offset-anchor property animated</h1> <div id="frameDiv"> <div id="pinkDiv"></div> <div id="circleDiv"></div> <svg> <path d="M 50 80 L 350 80" fill="none" stroke="gray" stroke-width="2" stroke-dasharray="5,5"/> </svg> </div> <p>The pink element is first "anchored" to the path at the bottom left corner point. Within 5 seconds the achored point is moved to the top left corner of the pink box.</p> </body> </html>