CSS Animations
CSS Animations
CSS Animations
CSS Animations
• CSS allows animation of HTML elements without using
JavaScript or Flash!
• learn about the following properties:
✔ @keyframes
✔ animation-name
✔ animation-duration
✔ animation-delay
✔ animation-iteration-count
✔ animation-direction
✔ animation-timing-function
✔ animation-fill-mode
✔ animation
What are CSS Animations?
• An animation lets an element gradually change
from one style to another.
div {
width: 100px;
height: 100px;
position: relative;
background-color: red;
animation-name: example;
animation-duration: 4s;
animation-direction: reverse;
}
animation-timing-function property
• The animation-timing-function property specifies the speed
curve of the animation.
• The animation-timing-function property can have the following
values:
• ease - Specifies an animation with a slow start, then fast, then
end slowly (this is default)
• linear - Specifies an animation with the same speed from start
to end
• ease-in - Specifies an animation with a slow start
• ease-out - Specifies an animation with a slow end
• ease-in-out - Specifies an animation with a slow start and end
• cubic-bezier(n,n,n,n) - Lets you define your own values in a
cubic-bezier function
<!DOCTYPE html> @keyframes mymove {
<html>
<head>
from {left: 0px;}
<style> to {left: 300px;}
div { }
width: 100px; </style></head>
height: 50px;
<body>
background-color: red;
font-weight: bold;
<p><strong>Note:</strong> The
position: relative; animation-timing-funtion property
animation: mymove 5s infinite; </p>
}