Deploying Icon Fonts for the Web
Illustration by John Hersey

Animating icons


Deploying Icon Fonts for the Web

with James Williamson

Video: Animating icons

In this exercise, I want to take a look And then you have to name your animation, whatever you want to call it.

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now
please wait ...
Watch the Online Video Course Deploying Icon Fonts for the Web
2h 4m Intermediate Apr 29, 2014

Viewers: in countries Watching now:

Icon fonts are a fast, effective way to feature scalable vector artwork on websites. James Williamson shows you how to properly deploy icon fonts on your own site in this short course. Learn how to find an icon font that's right for you and style it so it appears exactly the way you want. Then learn about deployment options that will make your icons accessible and display consistently across multiple browsers and devices. James also introduces advanced styling options such as animated and multicolored glyphs.

Want to create your own icon fonts? Check out James' companion course, Creating Icon Fonts for the Web.

Topics include:
  • Finding icon fonts
  • Ensuring consistent styling
  • Exploring class-based solutions for deployment
  • Deploying with the data-icon attribute
  • Aligning icons
  • Animating icons
  • Styling multicolored glyphs
James Williamson

Animating icons

In this exercise, I want to take a look at extending the styling of our icon fonts past just sort of basic visual styling into something a little bit more complex, like animating it through CSS. A lot of icon sets have icons that are designed to animate. Most notably, loader icons like the one you are seeing here at the bottom of the page. So what we're going to do is we're going to animate our loader icon by making it spin. And thus, simulate the loading of a page or element. Or widget or something like that. Now, I want to point out that as we are going through and styling this, I want you to notice that CSS animation support is pretty good right now.

However, you do have to work hard sometime to make sure that it works correctly across multiple browsers. Okay so here we are in the same file within the code editor. This the animate.htm. I want to scroll down and show you guys kind of how the icon is being displayed. It's right there in the paragraph. And we're not doing anything different from the way we normally display our icons, so we're still using data icon attribute, we're still using aria hidden. I've got some alt text there that of course we're hiding for accessibilities sake.

So really we don't need to make any changes as far as our deployment strategy goes. Okay I'm going to switch over to my CSS and I'm going to scroll all the way down to the bottom where we have our icon font styles. Again so this is just sort of our global icon style. The first thing that I want to do anytime that I'm doing animation Is I have to set the animation up before hand. And we do that using an at key frames rule. So I'm going to type in at key frames. And then you have to name your animation, whatever you want to call it.

And I think naming it loading makes a little bit of sense, since that is what we're simulating. And then inside of that, there are a couple of different ways this syntax works. Essentially You just basically say, hey, it looks this way at this state, and then this way at this state. And you can have as many states in there as you want, so you can create steps for your animation, or key frames, if you will. So it's a pretty cool way of working. I'm just going to go from 0% of the animation done, and then inside of that. And I always like sort of typing in the opening and closing curling braces to start, because when you start nesting them like that it's really easy to get lost.

Okay so I'm going to do a transform here and I'm going to transform this by rotating it. And I'm going to rotate it zero. Meaning it looks exactly the way it did when it started. So when it's at zero It's essentially at the start position. Now again, I love copying and pasting. So I'm going to copy this. Paste it. And this one is going to be 100% of the animation, and that's the animation being finished. So it's going from zero, start. To 100% finished and if we wanted to we could have multiple sets here, you have zero, 50, 100, anyway that we wanted to do this.

Okay, so since we wanted to spend all the way around we're going to give it a 360 degree rotation and for that transform value We do 360 and then DEG for degrees. All right now. Let me save this. Now at this point, animating it should be pretty easy. All I've go to do, is go down into the element that's controlling my icon and call the animation. So I'm going to go right down after line height and I'm going to type in animation. And the name of this animation is loading. Remember, we named it right up top.

So I'm pulling the name from there. Then we have to say how long we want the animation to take. And I want it to complete its rotation in one second, which will be pretty fast. How many times do I want it to rotate? I want it to rotate an infinite number of times. I don't want it to stop. So you can say, you know, we want it to rotate twice, or three times. In this case I'm going to say infinite. And then we have to tell it what kind of timing we want for the animation. TIming is basically things like easing. For easing you can have things accelerate at the beginning and slow down at the end. Slow down at first and then accelerate towards the end.

I just want linear because I want one nice constant speed the whole way through. Now if I save this, I go into one of my browsers and refresh it, I get absolutely zilch, nothing. Well, we've gotta remember what type of element we're inside of. Right now, we're in a span, which is in-line element. And animation is not going to work on in-line element, so I'm going to type in display. Inline_block. Save that.

Preview it, okay great. Now it's, it's spinning that's exactly what I wanted. So one of the things we have to remember is that if you do have an in line element, and icons are typically inline depending upon where you're using em. You at least have to make it into an inline block element in order to actually transform it, so that has everything to do with the properties that you're actually trying to animate, in this case, we're trying to animate the transform property. Okay, now you may have noticed that I was testing that in Firefox and throughout this entire course I've been testing it in Chrome, right? So what happens if I go over to Chrome, with the same page, and test it? Absolutely nothing.

And the reason for that, is the animation syntax has not been unprefixed yet. What does that mean? It means that a lot of browsers support animation, but they only support it through vendor prefixes. And Web Kit is certainly one of those. So, what I'm going to do, is I'm going to take my animation right here, I'm going to copy that. And then I'm going to paste a copy of it before that. We now have to add another version of our animation, this targeted specifically to WebKit. We do that by saying at _ webkit-keyframes.

So we've gotta change that. Then we have to remember that the transform property is also prefixed inside WebKit browsers. So now I have to prefix that and I have to do that twice, which makes me unhappy. There we go, we'll save that. And then finally, we're not quite done yet. I still go down and I have to call the animation again. So I'm going to copy this Paste it. Then I have to prefix that with webkit-animation. I'm going to go ahead and save that now, because I know this will do your heart a world of good.

There are also prefixes for Opera, there are prefixes for Mozilla for older versions of Firefox, and I think there are prefixes for IE. I'm pretty sure there are. All right. So I'm going to save that, go back out to Chrome, refresh and now I have my animated icon. So although animation can add a lot of visual punch to our using icon fonts, one of the things you want to be very careful with it is to make sure that you're testing it across multiple browsers and that you're really familiar with the syntax, so that you'll know when vendor prefixes are required.

And when to provide a fallback in case animation is not supported.

There are currently no FAQs about Deploying Icon Fonts for the Web.

Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed Deploying Icon Fonts for the Web.

Return to your organization's learning portal to continue training, or close this page.

Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.