Easy CSS Animated Flaming Text
By Stephen Bucaro
FIRE
CSS3 added many new features, one of them was the ability to create animations entirely in CSS, without
JavaScript. CSS animations are a way of chaining multiple transitions on the same property together to be
executed one after another.
.anim_fire
{
animation: fire 2.0s infinite alternate;
}
First define the animation. Above we define an animation named fire that will have a duration of
2.0 seconds. The infinite value means we want it to repeat forever. The alternate value means we want it
to reverse direction every cycle.
@keyframes fire
{
0%
{
text-shadow:
5px -25px 50px yellow,
0 0px 20px red,
10px -15px 15px orange;
}
33%
{
text-shadow:
0 -20px 30px yellow,
15px -5px 20px red,
5px 0 20px orange;
}
66%
{
text-shadow:
10px -25px 50px yellow,
5px -10px 20px red,
0 -5px 20px orange;
}
100%
{
text-shadow:
0 -20px 50px yellow,
5px -15px 20px red,
10px 0 20px orange;
}
}
Then we use the @keyframes directive, followed by the name of the animation, followed by a list of the steps,
or keyframes, in the animation.
Here, we have used percentage selectors which define the property values at specific percentages of the
animation duration time. The percentage defines at what point in the 2.0 second interval the specified property
values should be reached. The animation transitions from one set of property values to the next.
The property we used in the transition is the text-shadow property. Shown below is the syntax
for the text-shadow property.
text-shadow: horizontal-offset vertical-offset blur-radius color;
Note that I have defined three different shadow colors; yellow, red, and orange. The shadows are layered
in the order in which they are specified. The flame effect is created by changing the horizontal-offset
and vertical-offset values to move the shadows around.
<span class="anim_fire">
FIRE
</span>
Lastly, apply the animation to an html element. Here we defined the animation in a style class named .anim_fire,
which we applied to an html span element containing the text "FIRE".
You are free to experiment with your own horizontal-offset, vertical-offset, blur-radius, and color values.
CSS3 animations are fun and easy to create (assuming that you already know CSS), and you'll find many very
creative examples spread across the web.
More Easy Cascading Style Sheets: • Easy Floating Menu Code • Create a Cool Picture Frame Effect with CSS • Spice Up Your Web Forms with Color and Graphics • CSS to Use an Image as a Mask • Easy Text Drop Shadows • Easy CSS Popup Windows • Basic Introduction to Simple Responsive Design With Code • Create a No Image Rollover Button or Badge • How to Use a Starburst on Your Web Page • The CSS Box Model
|