运行 ❯
获取您
的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> #DIV1 { height: 200px; width: 200px; margin: auto; border: 1px solid black; } #DIV2 { width: 150px; height: 150px; border: 1px solid black; background-color: coral; translate: 0 0; animation: mymove 5s infinite; } @keyframes mymove { 50% {translate: -30px 50px;} } #DIV2original { position: absolute; width: 150px; height: 150px; border: 1px dashed grey; background-color: lightgrey; opacity: 0.5; } </style> </head> <body> <h1>Animation of translate</h1> <p>Gradually change the translate property from "0 0" to "-30px 50px", and back:<p> <p><b>Note: </b>The grey DIV element indicates where the DIV2 element would be without the change in translate property.</p> <div id="DIV1">DIV1 <div id="DIV2original">DIV2</div> <div id="DIV2">DIV2</div> </div> </body> </html>