animationName 속성은 @keyframes 참조에 대한 애니메이션 이름을 가져오거나 설정하는 데 사용됩니다.
구문
다음은 −
의 구문입니다.animationName 속성 설정 -
object.style.animationName = "none|keyframename|initial|inherit"
값
다음은 값입니다 -
| Sr.No | 값 및 설명 |
|---|---|
| 1 | 없음 애니메이션이 없을 것임을 언급하는 기본값입니다. |
| 2 | 키프레임 이름 선택기를 바인딩할 키프레임 이름을 지정합니다. |
| 3 | 초기 이 속성을 초기 값으로 설정합니다. |
| 4 | 상속 상위 속성 값을 상속합니다. |
예시
animationName 속성의 예를 살펴보겠습니다 -
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 60px;
height: 40px;
border: 10px groove fuchsia;
position: relative;
animation-name: bravo;
animation-iteration-count:infinite;
animation-duration: 5s;
}
@keyframes bravo {
from {left: 0px; }
to {left: 600px;}
}
@keyframes NEW_FRAME {
from {left:550px; }
to {left: 0px;}
}
</style>
<script>
function nameChange(){
document.getElementById("DIV1").style.animationName="NEW_FRAME";
document.getElementById("Sample").innerHTML="The animation name is now NEW_FRAME";
}
</script>
</head>
<body>
<div id="DIV1">SAMPLE TEXT</div>
<p>Click the below button to change the above animation fillmode property</p>
<button onclick="nameChange()">CHANGE NAME</button>
<p id="Sample"></p>
</body>
</html> 출력
그러면 다음과 같은 출력이 생성됩니다. 애니메이션이 왼쪽에서 오른쪽으로 이동합니다 -

CHANGE NAME 버튼을 클릭하면 애니메이션이 왼쪽에서 오른쪽으로 이동합니다 -
