css anomations 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: css animation
<style>
#ball {
width: 100px;
height: 100px;
margin: 50px auto;
position: relative;
border-radius: 50%;
background: linear-gradient(
35deg,
#ccffff,
#ffcccc
);
animation-name: bounce;
animation-duration: 1s;
animation-iteration-count: infinite;
animation-delay: 2s;
animation-direction: reverse;
animation-timing-function: linear;
}
@keyframes bounce{
0% {
top: 0px;
}
50% {
top: 249px;
width: 130px;
height: 90px;
}
100% {
top: 0px;
}
}
</style>
<div id="ball"></div>