December 5, 2024
It’s time for what has develop into a cherished vacation custom right here at Sinch E mail on Acid – the annual sharing of a tutorial on how one can use CSS animations to create a falling snow impact in your HTML emails. Are you able to consider a greater electronic mail geek present for the season?
We owe this custom to our pricey good friend and contributor Jay Oram of ActionRocket who first confirmed us how one can add wintry vibes in electronic mail campaigns six years in the past. Be sure you try extra of Jay and the ActionRocket team’s work – you’ll be impressed to go additional with electronic mail.
‘Tis the season for astonishing and delighting your subscribers, and this can be a enjoyable method to do it.
Can ChatGPT code falling snow for HTML emails?
Only for kicks, we determined to ask ChatGPT if it knew how one can code falling snowflakes in an HTML electronic mail. Right here’s the reply we acquired:
Creating falling snowflakes in an HTML electronic mail is difficult as a result of electronic mail purchasers have strict limitations on what CSS and JavaScript they assist. Nevertheless, you’ll be able to simulate falling snowflakes utilizing animated GIFs or embedded SVG animations, as these are extra broadly supported throughout electronic mail purchasers.
You’re not precisely improper, ChatGPT, however you’re not attempting laborious sufficient. Certain, we might have used a distinct immediate and saved attempting, but it surely’s the busy vacation season. Ain’t no one bought time for that.
The AI reply went on to supply a pair code snippets utilizing a GIF as a background or an inline SVG. However we’re speaking about one thing completely different right here.
This tutorial reveals you how one can get falling snowflakes within the foreground of your electronic mail utilizing CSS animations. The result’s an electronic mail marketing campaign with some depth of subject, virtually giving it a 3D impact. That could be overstating issues just a bit – but it surely’s fairly cool.
How an animated snowflake impact seems to be in electronic mail
Check out the e-mail publication 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 embrace little snowflakes gently falling down your display screen. In the event that they did… we’re additionally prepared to guess they discovered how right here.


This isn’t the form of factor you count on to see in a typical publication or electronic 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 would very properly imply greater open charges and increased email engagement. Now you’re subscribers shall be questioning what they may discover the subsequent time they try your electronic mail advertising campaigns.
You understand how a present at all times seems to be higher with a bow on high? Consider this as that final touch that makes opening an electronic mail include a bit vacation magic.
E mail consumer assist for CSS animations
Sadly, nothing in electronic mail improvement is ideal. This system 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 especially Apple Mail and Outlook for Mac in addition to Samsung and Thunderbird.
However for those who try your electronic mail analytics, that might be significant slice of your electronic mail subscribers. You’ll learn the way to focus on purchasers that assist CSS animations
Standing out within the inbox is a endless problem. Placing in a bit further effort on this means makes your emails memorable. However sufficient with the fluff. Let’s flip issues over to Jay Oram and learn the way to let it snow. Right here’s his animated snowflake tutorial for electronic mail builders trying to unfold vacation cheer.
Establishing the snowflake CSS animation
The snow impact is basically a snowflake or form in a div that you simply animate utilizing CSS. This system strikes the picture from the highest to the underside of a container div you place round your electronic mail tables.
CSS animations work on a spread of electronic mail purchasers together with iOS, Apple Mail, Android Native Mail and Outlook for Mac. The snow animation received’t show on different electronic mail purchasers, so that you don’t want to supply a fallback.
First, we arrange the media query to detect the webkit, that can assist the CSS animation.
@media display screen and (-webkit-min-device-pixel-ratio: 0) {
}
Subsequent, we arrange the container the snow shall be in.
.snowcontainer{
place:relative;
width:100%;
overflow:seen;
}
Creating your snowflakes
We then have to outline the snow. The only means to do that is to make use of a form that doesn’t want a picture, akin to a sq.. You’ll be able to 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 shall be positioned inside 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 seems to be like this:
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 means so as to add a snowflake is so as to add a background picture. This system is just like to the sq. method above, but it surely makes use of a background-image and no border-radius. With these modifications, the snowflake will seem like this:


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('photographs/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 Project’s snowflake icons.
Animating your snowflakes
With the code as is, we simply have some shapes inside a This animation is known as snow1. We outline the size of the animation as 5s (5 seconds) and the linear timing perform. The linear timing quantity retains the animation the identical pace all through – 0s (zero seconds) is the delay earlier than the animation begins once more. Lastly, we embrace the variety of occasions the animation will run (infinite).
By creating a couple of completely different animations with barely completely different lengths and delay time, the snow will fall at random.
Subsequent, we arrange the keyframe animations to dictate the place the snowflake will transfer to and from.
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 seem extra at random.
When you’ve created the CSS animation, you’ll want so as to add this impact to your electronic mail utilizing HTML. To create this animation method, the primary little bit of HTML you want is a
Subsequent, every particular person snowdrop must be set. To do that, begin with a Then, add in all of the snowdrops and animations inside the snow container. See beneath:
Place all of your electronic mail content material you desire to beneath your snowdrops and end with a closing to finish the Get all of the code and see it in motion from Jay Oram on CodePen.
Thanks once more to Jay Oram of ActionRocket for the tutorial and code snippets above.
Christmas solely comes annually, however you should utilize this CSS animation all 12 months lengthy for those who put your creativity cap on. Listed here are a couple of concepts to get you began:
It will also be raining cats and canine, or raining males (hallelujah), or turkeys or frogs might be falling out of the sky. Heck… you'll be able to drop tons of little poop emojis in emails if that’s your factor.
In fact, that is the sort of issues that stops being stunning and will simply begin to get annoying for those who over use it. So, if you'd like another concepts for creating participating emails, try these traditional episodes of Notes from the Dev: Video Edition with Megan Boshuyzen.
Rollover images are a easy but impactful means so as to add interactivity into electronic mail. Nout Boctor-Smith reveals you how one can pull it off.
For extra superior interactivity, Emre Demirel confirmed us how he gamified an email with a rock, paper, scissors you'll be able to play within the inbox.
Jay Oram introduced us much more inbox enjoyable with a Wordle game for email. And you'll comply with alongside as Megan Boshuyzen explains how she coded her award-winning interactive email for E mail Camp: Highway Journey Version.
.snow1{
animation: snow1 5s linear 0s infinite;
}
/* animation: Title of animation / size of animation / timing perform
(linear = identical pace from starting to finish) / delay (time between
animation finish and begin) / variety of occasions */
.snow2{
animation: snow2 6s linear 1s infinite;
}
.snow3{
animation: snow3 7s linear 2s infinite;
}
@keyframes snow1
{
0% { high:0%;left:50%; }
100% { high:100%;left:65%; }
}
@keyframes snow2
{
0% { high:0%;left:30%; }
100% { high:100%;left:25%; }
}
@keyframes snow3
{
0% { high:0%;left:70%; }
100% { high:100%;left:60%; }
}
HTML for the snowflake animation
snowcontainer.
Different methods to make use of this CSS animation in emails
Take your emails to the subsequent degree…
Source link