ในการตั้งค่าโหมดเติมสำหรับแอนิเมชั่นด้วย CSS ให้ใช้ animation-fill-mode คุณสมบัติ. มีค่าเดินหน้า ถอยหลัง ทั้งสองทิศทาง ฯลฯ
คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อตั้งค่าโหมดเติมสำหรับแอนิเมชั่น
ตัวอย่าง
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 150px;
height: 200px;
position: relative;
background: red;
animation-name: myanim;
animation-duration: 2s;
animation-fill-mode: forwards;
}
@keyframes myanim {
from {left: 0px; background-color: green;}
to {left: 200px; background-color: blue;}
}
</style>
</head>
<body>
<div></div>
</body>
</html>