המאפיין animation ב-CSS משמש להוספת אנימציות לאלמנט. באמצעות animation ניתן לקבוע את התכונות שיתאימו את האנימציה, את משך הזמן שלה, את מספר הפעמים שהיא תתבצע ואת האופן בו היא תתנהל.
באמצעות animation ניתן ליצור אנימציות מתקדמות באתרים, ולהוסיף אפקטים ויזואליים שיכולים לשפר את חוויית המשתמש.
להלן דוגמה לשימוש במאפיין animation:
באמצעות animation ניתן ליצור אנימציות מורכבות ולשלוט על התנהגותן בצורה מדויקת.
<style>
@keyframes example {
from { background-color: red; }
to { background-color: yellow; }
}
.animated {
animation-name: example;
animation-duration: 4s;
animation-timing-function: ease-in-out;
animation-delay: 1s;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-fill-mode: forwards;
}
</style>
<div class="animated" style="width: 100px; height: 100px;">
אנימציה
</div>
רק רגע