1<style>
2.my-element {
3 width: 100%;
4 height: 100%;
5 animation: tween-color 5s infinite;
6}
7
8@keyframes tween-color {
9 0% {
10 background-color: red;
11 }
12 50% {
13 background-color: green;
14 }
15 100% {
16 background-color: red;
17 }
18}
19
20html,
21body {
22 height: 100%;
23}
24<style>
25
26<body>
27 <div class="my-element"></div>
28</body>
1CSS animation properties template:
2{
3 animation-name: anima-name;
4 animation-duration: 1s;
5 animation-iteration-count: infinite;
6 animation-delay: 2s;
7 animation-direction: reverse | normal | alternate | alternate-reverse ;
8 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));
9 animation-fill-mode:forwards | backwards | both | none;
10}
11@keyframes anima-name {
12 from {
13 background-position:right;
14 }
15 to {
16 background-position:left;
17 }
18}
19@keyframes anima-name {
20 0% {
21 background-color: red;
22 }
23 50% {
24 background-color: green;
25 }
26 100% {
27 background-color: red;
28 }
29}
30
1<!DOCTYPE html>
2<html>
3<head>
4<style>
5div {
6 width: 100px;
7 height: 100px;
8 background-color: red;
9 position: relative;
10 animation: myfirst 5s linear 2s infinite alternate;
11}
12@keyframes myfirst {
13 0% {background-color:red; left:0px; top:0px;}
14 25% {background-color:yellow; left:200px; top:0px;}
15 50% {background-color:blue; left:200px; top:200px;}
16 75% {background-color:green; left:0px; top:200px;}
17 100% {background-color:red; left:0px; top:0px;}
18}
19</style>
20</head>
21<body>
22
23<p><b>Note:</b> This example does not work in Internet Explorer 9 and earlier versions.</p>
24
25<div><p>you can add text in this box or anithing else like a pictrue</p></div>
26
27</body>
28</html>
1Read this helpful, short and straightforward article to learn CSS animation perfectly.
2
3https://medium.com/@Cafe_Code/learn-css-animation-asap-as-simple-as-possible-374b7874d4dd
1 Name Last modified Size Description mail-notifiction.html 2021-05-12 01:38 4.4K Hypertext Markup Language
2 Day-night.html 2021-05-12 02:56 8.4K Hypertext Markup Language
3