index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Hiệu ứng Animation Motion Path CSS</title> <link rel="stylesheet" href="app.css"> </head> <body> <div id="motion-demo"> <img src="img/giphy.webp" /> </div> </body> </html>
app.css
#motion-demo { offset-path: path('M 0 0 L 0 175'); /* vẽ đường path theo chiều dọc để object chạy theo */ animation: move 3000ms infinite alternate ease-in-out; /* hoạt cảnh diễn ra trong 3s và lặp lại liên tục theo gia tốc */ width: 200px; height: 200px; background: cyan; border: 1px solid red; margin: 30px auto; transform: rotate(-90deg); } #motion-demo img { width: 100%; height: 100%; } @keyframes move { 0% { offset-distance: 0%; } 100% { offset-distance: 100%; } }
Thực hiện các bước tuần tự theo nội dung Bài học nhé!
Cùng nhau học tập, khám phá các kiến thức nền tảng về Lập trình web, mobile, database nhé.
Nền tảng kiến thức - Hành trang tới tương lai hân hạnh phục vụ Quý khách!
Khám phá, trải nghiệm ngay
Vui lòng đăng nhập để gởi bình luận!
Đăng nhậpChưa có bình luận nào!