w3 css animation code example
Example 1: css animation
<style>
.my-element {
width: 100%;
height: 100%;
animation: tween-color 5s infinite;
}
@keyframes tween-color {
0% {
background-color: red;
}
50% {
background-color: green;
}
100% {
background-color: red;
}
}
html,
body {
height: 100%;
}
<style>
<body>
<div class="my-element"></div>
</body>
Example 2: animation in css
/*
========================
Animation
========================
animation-name: We have to create our animation "example" etc.
animation-duration: 4s;
animation-delay: 1s;
animation-iteration-count: 4;
animation-direction: normal/reverse/alternate/alternate-reverse;
animation-timing-function: ease/ease-in/ease-out/ease-in-out;
animation-fill-mode: forwards/backward;
*/
@keyframes example {
from {
color: #a8dadcff;
}
to {
color: #e63946ff;
}
}
.animation {
animation-name: "example";
animation-duration: 4s;
animation-iteration-count: infinite;
animation-timing-function: ease-in-out;
/* animation-direction: reverse; */
}
Example 3: css animation
# css animaition .................... infinite dont stop
animation-name: example;
animation-duration: 1s;
animation-iteration-count: infinite;
@keyframes example {
0%{transform: rotate(0deg)}
50% {transform: rotate(5deg)}
75%{transform: rotate(0deg)}
100% {transform: rotate(50deg)}
}
Example 4: css animation
CSS animation properties template:
{
animation-name: anima-name;
animation-duration: 1s;
animation-iteration-count: infinite;
animation-delay: 2s;
animation-direction: reverse | normal | alternate | alternate-reverse ;
animation-timing-function: ease | ease-out | ease-in | ease-in-out | linear | cubic-bezier(x1, y1, x2, y2) (e.g. cubic-bezier(0.5, 0.2, 0.3, 1.0));
animation-fill-mode:forwards | backwards | both | none;
}
@keyframes anima-name {
from {
background-position:right;
}
to {
background-position:left;
}
}
@keyframes anima-name {
0% {
background-color: red;
}
50% {
background-color: green;
}
100% {
background-color: red;
}
}
Example 5: css animation linear
animation-timing-function: linear;
Example 6: animate.css
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css" />