Sunday, November 26, 2023
HomeEmail MarketingTips on how to Add a Snow Impact to an Electronic mail...

Tips on how to Add a Snow Impact to an Electronic mail Utilizing CSS Animation


css animation with snowflakes

Inboxes are all the time jammed up with vacation emails – there’s a variety of competitors. So, how will you make your electronic mail advertising and marketing campaigns stand out from the remaining? Attempt including a little bit of vacation cheer to your common emails by creating some animated snow utilizing CSS.

Right here’s what the impact seems to be like on a latest Electronic mail on Acid e-newsletter:

Email on Acid newsletter with snow effect

Setting Up the CSS Animation

The snow impact is actually a snowflake or form in a div that you just 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 shoppers together with iOS, Apple Mail, Android Native Mail and Outlook for Mac – try the Electronic mail on Acid final information to CSS animation for extra info. The snow animation received’t show on different electronic mail shoppers, so that you don’t want to supply a fallback.

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

@media display screen 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;
}

We then have to outline the snow. The best method to do that is to make use of a form that doesn’t want a picture, reminiscent of a sq.. You’ll be able to create a sq. by setting peak: 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 prime: -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:

shape snowflake

Right here’s the code for the form snowflake:

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

One other method 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:

snowflake image

Right here’s the code for the picture snowflake:

.snowimage{
  /* measurement of picture */
  peak:18px;
  width:18px;
  /* absolute - relative to the container div */
  place:absolute;
  /* The place animation begins */
  prime:-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 via it. Should you want some snowflake inspiration, try the Noun Venture’s snowflake icons.

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

.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 instances */

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 embrace the variety of instances the animation will run (infinite).

By creating a couple of totally different animations with barely totally 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% { prime:0%;left:50%; }
  100% { prime:100%;left:65%; }
 }

Firstly of the animation (0%), we place the snowflake on the prime 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 totally different in every animation, the snow will appear to look extra at random.

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

snowflake animation

The HTML for the Snowflake Animation

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 <div> to open the snow container. You’ll be able to set the peak and width of the container to determine the place the snow will present. For instance:

<div class="snowcontainer" type="width: 100%; peak: 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. Comply with that with the identify of the animation (e.g. snow1). The code ought to appear like this:

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

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

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

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

To see the snow in motion, try the total code right here.

Present Us What You’ve Acquired!

Have you ever tried this animation in one in all your vacation emails? Tell us the way it went or, higher but, present us! Share your expertise within the feedback part beneath or attain out on Fb or Twitter.



Writer: Jay Oram

Jay Oram is a part of the design and code options group on the electronic mail specialist company, ActionRocket. In his function at ActionRocket, Jay is normally experimenting with new code for emails or discovering that elusive rendering repair. See extra articles from Jay at emaildesignreview.com or discover him on Twitter at @emailjay_.

Writer: Jay Oram

Jay Oram is a part of the design and code options group on the electronic mail specialist company, ActionRocket. In his function at ActionRocket, Jay is normally experimenting with new code for emails or discovering that elusive rendering repair. See extra articles from Jay at emaildesignreview.com or discover him on Twitter at @emailjay_.





Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments