CSS animation Property

Description

The animation property is a shorthand property that is a comma-separated list of animation definitions, each of which combines seven of the animation properties into a single component value. To use the animation property, you must first define the animation itself using the @keyframes rule. The @keyframes rule specifies the keyframes for the animation, which are the points in time at which the element will have certain styles.

Initial value
see individual properties
Applies to
All elements, ::before and ::after pseudo elements
Inherited
See individual properties
Computed value
See individual properties
Animatable
No
JavaScript syntax
object.style.animation

Interactive Demo

Syntax

animation: <single-animation> [ ',' <single-animation> ]* 

Values

<single-animation> = <single-animation-name> || <time> || <single-animation-timing-function> || <time> || <single-animation-iteration-count> || <single-animation-direction> || <single-animation-fill-mode> || <single-animation-play-state>

Example

<div class="blink"></div> 
.blink { 
   width: 200px; 
   height: 200px; 
   border-radius: 50%; 
   background: #3ac; 
   position: relative; 
} 
.blink::before, .blink::after { 
   content: ""; 
   position: absolute; 
   width: 30px; 
   height: 40px; 
   border-radius: 50%; 
   background: #000; 
   top: 40px; 
   animation: eye 3s ease-in-out infinite; 
   -webkit-animation: eye 3s ease-in-out infinite; 
} 
.blink::before { 
   left: 55px; 
} 
.blink::after { 
   right: 55px; 
} 
@keyframes eye { 
   90% { 
      transform: none; 
   } 
   95% { 
      transform: scaleY(0.1); 
   } 
} 
@-webkit-keyframes eye { 
   90% { 
      transform: none; 
   } 
   95% { 
      transform: scaleY(0.1); 
   } 
} 

Browser Support

The following table will show you the current browser support for the CSS animation property.

Desktop
Edge Chrome Firefox Opera Safari
124316309
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
4316309443

Last updated by CSSPortal on: 31st December 2023