When these three properties are animated at once, it produces a coherent animation. The keyframe my-animation changes three style properties of our div: background-color, width, and top. A keyframe defines the animation’s starting state (inside from). The animation itself is created with a keyframe, indicated by the rule. Below that are several additional declarations that affect the timing and behavior of the animation. The most important declaration here is animation-name, which binds the keyframe my-animation to our div element. Looking at the CSS, we see that our animation declarations are associated with the div selector. In this example, is the element we’re animating. See the Pen CSS Animation Example by Christina Perricone ( on CodePen. To demonstrate, here’s a simple example of a CSS animation: You can also add declarations to further customize your animation, like speed and delay. To make a CSS animation, you need three things: an HTML element to animate, a CSS rule which binds the animation to this element, and a group of keyframes that defines the styles at the start and end of the animation. Since they don’t require extra scripts, CSS animations are unlikely to slow down your pages. GIFs) - everything is done with HTML and CSS.ĬSS animations are great for websites that want to add dynamic, engaging content without placing much more weight on the page. Pure CSS animations require no additional code (e.g. How do CSS animations work?ĬSS animation is a feature of CSS that allows you to animate a change in one or more style properties of an element, as well as control various aspects of the animation. That’s why we’ve compiled our favorite examples of CSS animation from CodePen - an online tool for creating and sharing code snippets in HTML and CSS - to help get the creative juices flowing.īut first, a brief review of the topic at hand. This extra bit of research can inspire your own projects and provide a sense of what you can accomplish with this powerful feature. If you want to add CSS animations to your work, it can be helpful to look at some successful uses of CSS animations first before diving in. While there are several ways to add animated graphics to a web page, one of the easiest is using CSS animations, which require nothing more than some HTML and CSS know-how to pull off.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |