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>