HTML Email Development, v2

Keyframe Animations Introduction

HTML Email Development, v2

Check out a free preview of the full HTML Email Development, v2 course

The "Keyframe Animations Introduction" Lesson is part of the full, HTML Email Development, v2 course featured in this preview video. Here's what you'd learn in this lesson:

Jason introduces keyframe animations as another way of making emails interactive, demonstrate how to code keyframes, and how to add them to an email.


Transcript from the "Keyframe Animations Introduction" Lesson

>> Jason Rodriguez: The next step up from that is going to be using keyframe animation, so CSS animations inside of your email. So this is cool cuz you can do more complex stuff using CSS animations. That keyframes property allows you to set different waypoints for when things should occur in your animations.

So you can create really complex stuff. We're gonna see a pretty simple example. And then you can pair this again with that transition property to make everything kinda fade in and out, or move around nicely and look really smooth. So if you're not familiar with CSS keyframes, there's a couple of things you need to worry about.

The main thing driving this is the @keyframes property inside of CSS. So this will go on the head of your document. And it tells the rendering engine that you're setting up this animation that you want to then call at some point. So the way this works is you have your keyframes.

And then you have your animation name here, and that's what you're going to call later on for your element. In this case, it's called animation-name. And then, we have a class of whatever the element is we're targeting and trying to animate. And we'll call that name down here using this animation property.

So inside of the keyframe's curly braces you have different states that you're setting up. So you can do something simple like save from the state, from these properties to this end state. That can be anything from the background color or the color of an element through to the positioning.

You can move things around the screen, you can do all kinds of crazy stuff inside of keyframe animations. You could get more complex and have different steps by using percentages inside of that, 0 to 100%. So if you want one thing to happen in the first 20% of that animation, then you'd say 20% and then set all of your properties.

Then you could do 30%, 50%, 70%. So you can have this stepped approach to your animations, and using that you can create some pretty complex stuff. For our purposes, we're just gonna have simple states. We're gonna have a faded out state, and then a faded in state for our element so there's this nice fading in animation for our email campaign.

So if you open it up and it looks cool, it kinda draws your attention to the campaign but it's not overpowering or anything like that. So we'll just use from and to. So you're going from one state, the initial state, to another state, which is that end state.

And then for any element we want to apply this animation to, we use this animation CSS property which takes a whole bunch of different rules in there, different properties. But the main ones we're looking at are the duration of the animation itself, how many times we want the animation to play through.

And then calling the name of the animation, that keyframe animation that we originally set up.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now