So, a little while ago I talked about using CSS3 animations in your landing pages. They're great - they give you a lot of the attention-grabbing elements of animated GIFs without the filesize problems.
But how do you do that?
Well, today I'm going to show you one simple use of CSS animations: creating an animated Call To Action for your lander.
Animated CTAs are well known to provide a subtle boost to CTR, but using them for mobile has always been a bit tricky, because of the filesize implications of adding an animated GIF. But now, you can use CSS to animate them with no loading time slowdown whatsoever - and they'll look smoother than GIFs in the bargain!
What Do I Need To Do This?
You'll need to be able to edit the HTML of your lander, and have a basic understanding of HTML tags.
Beyond that, you don't need any coding knowledge to use the basic version of this technique. Some knowledge of Javascript might be handy if you want to get a little more advanced, but I'll explain most of what you need to know.
How To Do It
Setting this up is actually incredibly simple.
First, add a couple of items to your CTA. You'll need to add a new class called "attention", and you may need to change the display type of your CTA to be "block".
To do that, just add
to your CTA's surrounding HTML tag.
For example, if your CTA was
then you would change it to be
Now, just before the closing </body> tag of your landing page, add the following code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/snabbt.js/0.5.1/snabbt.min.js"></script>
<script type="text/javascript">
(function(window, document, snabbt) {
function CallToAction() {
snabbt(document.querySelectorAll('.attention'), 'attention', {
scale: [1.4, 1.4, 0],
springConstant: 1.9,
springDeceleration: 0.9,
});
}
setInterval(CallToAction, 1500);
})(window, document, window.snabbt);
</script>
Thanks caurmen for this great sharing. I'll definitely test it asap. 
I just noticed that the last curly bracket is too much in code.
<script src="https://cdnjs.cloudflare.com/ajax/libs/snabbt.js/0.5.1/snabbt.min.js"></script>
<script type="text/javascript">
(function(window, document, snabbt) {
function CallToAction() {
snabbt(document.querySelectorAll('.attention'), 'attention', {
scale: [1.4, 1.4, 0],
springConstant: 1.9,
springDeceleration: 0.9,
});
}
setInterval(CallToAction, 1500);
}
)(window, document, window.snabbt);
</script>
Great guide. I spent the day figuring out his rotating text. Coincidence to find your guide now after messing around all day. Thanks
Advice anyone..
I've managed to combine Caurmen's example with the attention animation button example on the Snabbt site..
Any idea how I would fade the element in? Say after 4000 period?
I've tried using the opacity with a delay/duration etc.. but can't seem to get it working..
This is what I have that is working with a 4000 delay to start animating .. What I want it is fade in, then begin animation after 4000ms
(function(window, document, snabbt) {
function CallToAction() {
snabbt(document.querySelectorAll('.attention'), 'attention', {
rotation: [0, 0, Math.PI/3],
springConstant: 2.3,
springDeceleration: 0.4,
duration: 3000,
});
}
setInterval(CallToAction, 4000);
}
)(window, document, window.snabbt);
@Mr App - dammit, you're right! That'll teach me to pull out an extraneous bit of code before publication and not test it. Edited - thank you.
@elephant - no worries!
@dynamicsoul - You'll need to animate the opacity outside an attention animation - in further testing, I've discovered that it doesn't seem to work as an attention animation.
This code will fade an element in over the time specified in "duration". You'll need to set the initial opacity of the element to 0 in the CSS.
snabbt(document.querySelectorAll('.attention'), {
opacity: 1,
fromOpacity: 0,
duration: 2000,
});
}
setTimeout(FadeIn, 1500);
nice library. I used something like this on affkit, but it's css3. This looks very customizable and fast.
Thanks Caurmen, I'll try get it working tomorrow when I have time to play. For now I did a display:none and javascript fade on a div haha.. easy hack.
Thank you, but i have an issue, my button disappear after applying this method and i get just animated text, how can i fix that please ? my button show up with this code : <a href="tracking link"class="css3button" aign="center">download</a>
and not when i add : <a href="tracking link"class="attention"style="display:inline-block">download</a>
Yes perfectly, thank you 