Https WWW W3schools Com Css css3 Animations Asp
Https WWW W3schools Com Css css3 Animations Asp
Https WWW W3schools Com Css css3 Animations Asp
w3schools.com
CSS Opacity
CSS Navigation Bar
THE WORLD'S LARGEST WEB DEVELOPER
CSS Dropdowns
HTML CSS JAVASCRIPT SQL MORE REFERENCES EXERCISES
CSS Image Gallery
CSS Image Sprites
CSS Attr Selectors
CSS Forms
CSS Counters
CSS Website Layout
CSS Units
CSS Specificity
CSS Animations
❮ Previous Next ❯
CSS Advanced
CSS Rounded Corners
CSS Border Images
CSS Backgrounds CSS Animations
CSS Colors
CSS Gradients CSS allows animation of HTML elements without using JavaScript or Flash!
CSS Shadows
CSS Text Effects CSS
CSS Web Fonts
CSS 2D Transforms In this chapter you will learn about the following properties:
CSS 3D Transforms
CSS Transitions @keyframes
CSS Animations animation-name
CSS Tooltips animation-duration
CSS Style Images animation-delay
CSS object-fit animation-iteration-count
CSS Buttons animation-direction
PDF created on https://www.htm2pdf.co.uk via the HTML to PDF API
animation-timing-function COLOR
animation-fill-mode
PICKER
animation
Tabs
Dropdowns
Accordions
Side
Navigation
Top
Navigation
Modal
Boxes
Progress
Bars
Parallax
Login Form
HTML
Includes
Google
Maps
Range
Sliders
Tooltips
Slideshow
Filter List
Sort List
PDF created on https://www.htm2pdf.co.uk via the HTML to PDF API
Property
SHARE
@keyframes 43.0 10.0 16.0 9.0 30.0
animation-name 43.0 10.0 16.0 9.0 30.0
div {
width: 100px;
height: 100px;
background-color: red;
animation-name: example;
animation-duration: 4s;
}
@keyframes example {
from {background-color: red;}
to {background-color: yellow;}
}
Try it Yourself »
You can change as many CSS properties you want, as many times you want.
To use CSS animation, you must first specify some keyframes for the animation.
Keyframes hold what styles the element will have at certain times.
The following example binds the "example" animation to the <div> element. The
animation will last for 4 seconds, and it will gradually change the background-color
of the <div> element from "red" to "yellow":
Example
Try it Yourself »
In the example above we have specified when the style will change by using the
keywords "from" and "to" (which represents 0% (start) and 100% (complete)).
It is also possible to use percent. By using percent, you can add as many style
changes as you like.
The following example will change the background-color of the <div> element when
the animation is 25% complete, 50% complete, and again when the animation is
100% complete:
Example
The following example will change both the background-color and the position of the
<div> element when the animation is 25% complete, 50% complete, and again
when the animation is 100% complete:
Example
Try it Yourself »
The following example has a 2 seconds delay before starting the animation:
Example
div {
width: 100px;
height: 100px;
position: relative;
background-color: red;
animation-name: example;
animation-duration: 4s;
animation-delay: 2s;
}
Try it Yourself »
Negative values are also allowed. If using negative values, the animation will start
as if it had already been playing for N seconds.
In the following example, the animation will start as if it had already been playing
for 2 seconds:
div {
width: 100px;
height: 100px;
position: relative;
background-color: red;
animation-name: example;
animation-duration: 4s;
animation-delay: -2s;
}
Try it Yourself »
The following example will run the animation 3 times before it stops:
Example
div {
Try it Yourself »
The following example uses the value "infinite" to make the animation continue for
ever:
Example
div {
width: 100px;
height: 100px;
position: relative;
background-color: red;
animation-name: example;
animation-duration: 4s;
animation-iteration-count: infinite;
}
Try it Yourself »
The following example will run the animation in reverse direction (backwards):
Example
div {
width: 100px;
height: 100px;
position: relative;
background-color: red;
animation-name: example;
animation-duration: 4s;
animation-direction: reverse;
}
Try it Yourself »
Example
div {
width: 100px;
height: 100px;
position: relative;
background-color: red;
animation-name: example;
animation-duration: 4s;
animation-iteration-count: 2;
animation-direction: alternate;
}
Try it Yourself »
The following example uses the value "alternate-reverse" to make the animation run
backwards first, then forwards:
Example
div {
width: 100px;
height: 100px;
position: relative;
background-color: red;
Try it Yourself »
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
The following example shows the some of the different speed curves that can be
used:
Example
PDF created on https://www.htm2pdf.co.uk via the HTML to PDF API
#div1 {animation-timing-function: linear;}
#div2 {animation-timing-function: ease;}
#div3 {animation-timing-function: ease-in;}
#div4 {animation-timing-function: ease-out;}
#div5 {animation-timing-function: ease-in-out;}
Try it Yourself »
The animation-fill-mode property specifies a style for the target element when
the animation is not playing (before it starts, after it ends, or both).
none - Default value. Animation will not apply any styles to the element
before or after it is executing
forwards - The element will retain the style values that is set by the last
keyframe (depends on animation-direction and animation-iteration-count)
backwards - The element will get the style values that is set by the first
keyframe (depends on animation-direction), and retain this during the
animation-delay period
both - The animation will follow the rules for both forwards and backwards,
extending the animation properties in both directions
Example
div {
width: 100px;
height: 100px;
background: red;
position: relative;
animation-name: example;
animation-duration: 3s;
animation-fill-mode: forwards;
}
Try it Yourself »
The following example lets the <div> element get the style values set by the first
keyframe before the animation starts (during the animation-delay period):
Example
div {
width: 100px;
height: 100px;
background: red;
position: relative;
animation-name: example;
Try it Yourself »
The following example lets the <div> element get the style values set by the first
keyframe before the animation starts, and retain the style values from the last
keyframe when the animation ends:
Example
div {
width: 100px;
height: 100px;
background: red;
position: relative;
animation-name: example;
animation-duration: 3s;
animation-delay: 2s;
animation-fill-mode: both;
}
Try it Yourself »
Example
div {
animation-name: example;
animation-duration: 5s;
animation-timing-function: linear;
animation-delay: 2s;
animation-iteration-count: infinite;
animation-direction: alternate;
}
Try it Yourself »
The same animation effect as above can be achieved by using the shorthand
animation property:
Example
div {
animation: example 5s linear 2s infinite alternate;
}
Exercise 5 » Exercise 6 »
Property Description
animation-fill-mode Specifies a style for the element when the animation is not
playing (before it starts, after it ends, or both)
❮ Previous Next ❯