>  기사  >  웹 프론트엔드  >  animation-direction 속성을 사용하는 방법

animation-direction 속성을 사용하는 방법

青灯夜游
青灯夜游원래의
2019-01-31 11:42:575495검색

animation-direction 속성은 애니메이션을 차례로 역방향으로 재생할지 여부를 정의하는 데 사용됩니다. 애니메이션이 두 번 이상 재생되는 경우 animation-direction 값을 교대로 설정하여 역방향 애니메이션을 구현할 수 있습니다.

animation-direction 속성을 사용하는 방법

CSS3 애니메이션 방향 속성

기능: 애니메이션을 차례로 역방향으로 재생할지 여부를 정의합니다.

구문: ​​

animation-direction: normal|alternate;

normal: 기본값. 애니메이션이 정상적으로 재생되어야 합니다.

대안: 애니메이션이 차례로 역방향으로 재생되어야 합니다.

참고: animation-direction 값이 "alternate"인 경우 애니메이션은 홀수(1, 3, 5 등)에서는 정상적으로 재생되고 짝수(2, 4, 6 등)에서는 뒤로 재생됩니다. ) .

참고: 애니메이션이 한 번만 재생되도록 설정된 경우 이 속성은 효과가 없습니다.

CSS3 animation-direction 속성 사용 예

<!DOCTYPE html>
<html>
<head>
<style> 
div
{
width:100px;
height:100px;
background:red;
position:relative;
animation:myfirst 5s infinite;
animation-direction:alternate;

/* Safari and Chrome */
-webkit-animation:myfirst 5s infinite;
-webkit-animation-direction:alternate;
}

@keyframes myfirst
{
0%   {background:red; left:0px; top:0px;}
25%  {background:yellow; left:200px; top:0px;}
50%  {background:blue; left:200px; top:200px;}
75%  {background:green; left:0px; top:200px;}
100% {background:red; left:0px; top:0px;}
}

@-webkit-keyframes myfirst /* Safari and Chrome */
{
0%   {background:red; left:0px; top:0px;}
25%  {background:yellow; left:200px; top:0px;}
50%  {background:blue; left:200px; top:200px;}
75%  {background:green; left:0px; top:200px;}
100% {background:red; left:0px; top:0px;}
}
</style>
</head>
<body>

<div></div>

</body>
</html>

Rendering:

animation-direction 속성을 사용하는 방법

위는 이 글의 전체 내용입니다. 모든 분들의 학습에 도움이 되기를 바랍니다. 더 흥미로운 내용을 보려면 PHP 중국어 웹사이트의 관련 튜토리얼 열을 주의 깊게 살펴보세요! ! !

위 내용은 animation-direction 속성을 사용하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.