Tuesday, November 28, 2023
HomeEmail MarketingThe best way to Use CSS Animation in Your Vacation Emails

The best way to Use CSS Animation in Your Vacation Emails


css animation with snowflakes

The vacations and little surprises go collectively like sizzling cocoa and marshmallows. On the lookout for a manner so as to add just a little additional pleasure to your vacation e-mail campaigns? We’ve obtained the proper inbox stocking-stuffer.

It’s been 5 years since our good friend Jay Oram of ActionRocket confirmed us the best way to create animated falling snowflakes in an HTML e-mail. We took out our snow shovels to dig it up once more so you may improve emails and shock your subscribers with some vacation magic.

How an animated snowflake impact appears to be like in e-mail

Check out the e-mail e-newsletter Jay coded up for us again within the day. We’re prepared to guess many of the emails you opened over Black Friday and Cyber Monday didn’t embody little snowflakes gently falling down your display.

Email on Acid newsletter with snow effect

This isn’t the kind of factor you count on to see in a typical e-newsletter or e-mail promotion. However right here’s the factor… When you’ve shattered your subscribers’ expectations, you’ve set the stage for much more inbox surprises.

That might very properly imply greater open charges and elevated e-mail engagement. Now you’re subscribers will likely be questioning what they could discover the subsequent time they try your e-mail advertising campaigns.

You know the way a present at all times appears to be like higher with a bow on high? Consider this

E mail consumer help for CSS animations

Sadly, nothing in e-mail improvement is ideal. This method makes use of CSS animation and keyframes. Based on CanIEmail.com, these are solely supported in purchasers utilizing WebKit because the rendering engine, which is principally Apple Mail and Outlook for Mac in addition to Samsung and Thunderbird.

However in case you try your e-mail analytics, that might be significant slice of your e-mail subscribers. You’ll learn how to focus on purchasers that help CSS animations

Standing out within the inbox is a endless problem. Placing in just a little additional effort on this manner makes your emails memorable. However sufficient with the fluff. Let’s flip issues over to Jay Oram and learn how to let it snow. Right here’s his animated snowflake tutorial for e-mail builders seeking to unfold vacation cheer.


Organising the snowflake CSS animation

The snow impact is basically a snowflake or form in a div that you simply animate utilizing CSS. This method strikes the picture from the highest to the underside of a container div you place round your e-mail tables.

CSS animations work on a variety of e-mail purchasers together with iOS, Apple Mail, Android Native Mail and Outlook for Mac. The snow animation gained’t show on different e-mail purchasers, so that you don’t want to offer a fallback.

First, we arrange the media question to detect the webkit, that may help the CSS animation.

@media display and (-webkit-min-device-pixel-ratio: 0) {
}

Subsequent, we arrange the container the snow will likely be in.

.snowcontainer{
  place:relative;
  width:100%;
  overflow:seen;
}

Creating your snowflakes

We then have to outline the snow. The best manner to do that is to make use of a form that doesn’t want a picture, corresponding to a sq.. You possibly can create a sq. by setting top: 18px by width: 18px and setting a border-radius that’s half the peak (to realize an ideal circle), border-radius: 9px. Set the place:absolute  so the snow will likely be positioned throughout the container and high: -20px to begin the animation earlier than it enters the snowcontainer. Lastly, add a background-color to set the colour of the form.

It appears to be like like this:

shape snowflake

Right here’s the code for the form snowflake:

.snow{
            top: 18px;
            border-radius: 9px;
            width: 18px;
            place: absolute;
            high: -20px;
            background-color: #ffffff;
      }

One other manner so as to add a snowflake is so as to add a background picture. This method is just like to the sq. method above, nevertheless it makes use of a background-image and no border-radius. With these adjustments, the snowflake will appear as if this:

snowflake image

Right here’s the code for the picture snowflake:

.snowimage{
  /* dimension of picture */
  top:18px;
  width:18px;
  /* absolute - relative to the container div */
  place:absolute;
  /* The place animation begins */
  high:-20px;
  /* picture hyperlink */
  background-image:url('pictures/snowflake.png');
}

Setting the background-image as a .png means the snowflake can have a clear background and present the content material by means of it. If you happen to want some snowflake inspiration, try the Noun Mission’s snowflake icons.

Animating your snowflakes

With the code as is, we simply have some shapes inside a <div>. To animate them, we are able to put collectively a shortened model of an animation. See under:

.snow1{
  animation: snow1 5s linear 0s infinite;
 }
 /* animation: Identify of animation / size of animation / timing operate 
(linear = similar velocity from starting to finish) / delay (time between 
animation finish and begin) / variety of occasions */

This animation is named snow1. We outline the size of the animation as 5s (5 seconds) and the linear timing operate. The linear timing quantity retains the animation the identical velocity all through – 0s (zero seconds) is the delay earlier than the animation begins once more. Lastly, we embody the variety of occasions the animation will run (infinite).

By creating a number of completely different animations with barely completely different lengths and delay time, the snow will fall at random.

.snow2{
  animation: snow2 6s linear 1s infinite;
 }
 .snow3{
  animation: snow3 7s linear 2s infinite;
 }

Subsequent, we arrange the keyframe animations to dictate the place the snowflake will transfer to and from.

@keyframes snow1
 {
  0% { high:0%;left:50%; }
  100% { high:100%;left:65%; }
 }

Initially of the animation (0%), we place the snowflake on the high of the div (0%) and 50% from the left. On the finish of the animation (100%) the snowflake is 100% from the highest and 65% from the left.

By setting the beginning and finish factors barely completely different in every animation, the snow will appear to look extra at random.

@keyframes snow2
 {
  0% { high:0%;left:30%; }
  100% { high:100%;left:25%; }
 }
 @keyframes snow3
 {
  0% { high:0%;left:70%; }
  100% { high:100%;left:60%; }
 }
snowflake animation

HTML for the snowflake animation

When you’ve created the CSS animation, you’ll want so as to add this impact to your e-mail utilizing HTML. To create this animation method, the primary little bit of HTML you want is a <div> to open the snow container. You possibly can set the peak and width of the container to determine the place the snow will present. For instance:

<div class="snowcontainer" model="width: 100%; top: 500px;">

Subsequent, every particular person snowdrop must be set. To do that, begin with a <div> with the category of the snowimage or snow as arrange in your CSS. Observe that with the title of the animation (e.g. snow1). The code ought to seem like this:

<div class="snowimage snow1"></div>

Then, add in all of the snowdrops and animations throughout the snow container. See under:

<div class="snowcontainer" model="top: 500px;">
  <div class="snowimage snow1"></div>
  <div class="snow snow2"></div>
  <div class="snow snow3"></div>

Place all of your e-mail content material you desire to under your snowdrops and end with a closing </div> to finish the snowcontainer.

Get all of the code and see it in motion from Jay Oram on CodePen.


Different methods to make use of this CSS animation in emails

Thanks once more to Jay Oram of ActionRocket for the tutorial and code snippets above.

Christmas solely comes annually, however you should use this CSS animation all 12 months lengthy in case you put your creativity cap on. Listed here are a number of concepts to get you began:

  • Autumn leaves for fall themed emails. This might be a approach to have enjoyable with back-to-school e-mail advertising.
  • Colourful falling confetti to have a good time absolutely anything, together with birthdays, anniversaries, and different milestone emails.
  • Matrix-style raining code might be a memorable approach to improve emails to a tech-savvy viewers.

It may also be raining cats and canines, or raining males (hallelujah), or turkeys or frogs might be falling out of the sky. Heck… you may drop tons of little poop emojis in emails if that’s your factor.

Take your emails to the subsequent stage…

In fact, that is the form of issues that stops being shocking and will simply begin to get annoying in case you over use it. So, if you need another concepts for creating partaking emails, try these traditional episodes of Notes from the Dev: Video Version with Megan Boshuyzen.

Rollover pictures are a easy but impactful manner so as to add interactivity into e-mail. Nout Boctor-Smith exhibits you the best way to pull it off.

For extra superior interactivity, Emre Demirel confirmed us how he gamified an e-mail with a rock, paper, scissors you may play within the inbox.

Jay Oram introduced us much more inbox enjoyable with a Wordle sport for e-mail. And you may comply with alongside as Megan Boshuyzen explains how she coded her award-winning interactive e-mail for E mail Camp: Street Journey Version.



Creator: The E mail on Acid Workforce

The E mail on Acid content material group is made up of digital entrepreneurs, content material creators, and straight-up e-mail geeks.

Join with us on LinkedIn, comply with us on Fb, and tweet at @EmailonAcid on Twitter for extra candy stuff and nice convos on e-mail advertising.

Creator: The E mail on Acid Workforce

The E mail on Acid content material group is made up of digital entrepreneurs, content material creators, and straight-up e-mail geeks.

Join with us on LinkedIn, comply with us on Fb, and tweet at @EmailonAcid on Twitter for extra candy stuff and nice convos on e-mail advertising.



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments