
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
Defining Keyframes in CSS3
To create keyframe animations in CSS3, define individual keyframe. Keyframes will control the intermediate animation steps in CSS3.
Following is the code for defining key frames in CSS3 −
Example
<!DOCTYPE html> <html> <head> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } div { width: 100px; height: 100px; background: red; position: relative; animation: colorChange 5s infinite; } @keyframes colorChange { from { background: red; left: 0px; } to { background: rgb(32, 229, 255); left: 300px; } } </style> </head> <body> <h1>Defining keyframes in CSS</h1> <div></div> <h2>The above square will change its color and position with time</h2> </body> </html>
Output
The above code will produce the following output −
After 5s the position and color will change as follows −
- Related Articles
- CSS3 Animation @keyframes
- Defining Colors in CSS3
- Moving left animation with keyframes using CSS3
- Set the name of the CSS @keyframes animation
- Defining static members in C++
- Defining a Function in Python
- Defining Class Methods in Perl
- Defining new functions in Arduino
- PHP Defining namespace
- Defining Clean Up Actions in Python
- Defining user lock settings in SAP HANA
- Defining a variable reference in SAP ABAP
- PHP Defining Multiple Namespaces in same file
- 2D transforms in CSS3
- 3D transforms in CSS3

Advertisements