CodeLab
Tutorials For Everyone
Run
<!DOCTYPE html> <html> <head> <style> #container { width: 400px; height: 180px; margin: 20px; position: relative; margin: auto; background-color: #f8f9fa; box-shadow: 0 0 10px 0 #aaa; } svg { position: absolute; height: 100%; width: 100%; left: 0; top: 0; } img { position: absolute; z-index: 1; width: 70px; offset-path: path('M 50 80 C 150 -20 250 180 350 80'); animation: moveFish 5s infinite; } @keyframes moveFish { 0% { offset-distance: 0%; opacity: 1; } 80% { opacity: 0.9;} 100% { offset-distance: 100%; opacity: 0; } } </style> </head> <body> <h1>Animatable 'offset-distance' Property</h1> <hr> <p>Fish moves along the path using the offset-distance property, which is animatable.</p> <div id="container"> <img id="fish1" src="images/fish.png" 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> </body> </html>