You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
2.8 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*,
body {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.animate {
width: 100px;
height: 100px;
background-color: blue;
margin: 100px;
animation-name: changeColor;
animation-duration: 5s;
animation-iteration-count: infinite;
animation-fill-mode: forwards;
/* animation-play-state: paused; */
animation-delay: 3s;
animation-direction: reverse;
}
.animated-2 {
width: 100px;
height: 100px;
background-color: green;
animation-name: change;
animation-duration: 5s;
animation-iteration-count: infinite;
position: relative;
}
@keyframes changeColor {
from {
background-color: blue;
width: 100px;
}
to {
background-color: red;
width: 300px;
}
}
@keyframes change {
0% {
background-color: green;
top: 0;
left: 0;
}
25% {
background-color: yellow;
top: 0;
left: 200px;
}
50% {
background-color: red;
top: 200px;
left: 200px;
}
78% {
background-color: blue;
top: 200px;
left: 0px;
}
100% {
background-color: aqua;
top: 0;
left: 0;
}
}
</style>
</head>
<!-- notes
برای ایجاد انیمیشن های خودکار استفاده میشود
@keyframes
animation
animation-delay
animation-direction
animaiton-duration
animation-fill-mode
animation-iterarion-count
animation-name
animation-play-state
animation-timing-function
animation-play-state
اینیمیشن به صورت پیشفرض بلیباشد یا نه
animation-fill-mode
forwards
backwards
animation-play-state:
paused
running
default: running
animation-timing-function:
animation-dalay: runs the animation after givven delay
animation-direction:
reverse -> starts from the end
alternated-reverse
short hand:
animation: animationName animation-duration timing-fucntion delay iteration-count direction fill-mode play-state
-->
<body>
<div class="animate"></div>
<hr>
<div class="animated-2"></div>
</body>
</html>