From our sponsor: Meco is a distraction-free space for reading and discovering newsletters, separate from the inbox.
Today we have a neat little effect for you. We want to bring some life to the standard hover effect by playing around with the letters in an anchor word. The aim is to slide in letter by letter when hovering over a link element. We can either have the same word or a different one and we can slide in the new letters all the same time or one after the other.
We will be using the Lettering.js jQuery Plugin which you can find on Github.
Tiny break: 📬 Want to stay up to date with frontend and trends in web design? Subscribe and get our Collective newsletter twice a tweek.
Example
In the following we will go through an example and we’ll start by the html for a little menu:
<div class="sl_examples"> <a href="#" id="example1" data-hover="Creativity">Illustrations</a> </div>
We will use data-hover to indicate the word that should appear on hover. If you don’t use the data-hover then the same word will be used on hover.
Then we will style it in the following way, making sure that we have the right properties for the structure that will be generated:
.sl_examples{ float:left; font-family: 'Bevan', arial, serif; font-size:50px; line-height:50px; color:#f0f0f0; margin-right:5px; text-transform:uppercase; } .sl_examples a{ display:block; position:relative; float:left; clear:both; color:#fff; } .sl_examples a > span{ height:50px; float:left; position:relative; overflow:hidden; } .sl_examples a span span{ position:absolute; display:block; left:0px; top:0px; text-align:center; } .sl_examples a span span.sl-w1{ color:#fff; text-shadow:0px 0px 1px #fff; z-index:2; } .sl_examples a span span.sl-w2{ color:#e82760; text-shadow:-1px 1px 2px #9f0633; z-index:3; }
So, “sl-w1” is the class for the first word letters and “sl-w2” is the class for the second word letters.
Finally, we call the plugin:
$(window).load(function(){ $('#example1').hoverwords({ delay:50 }); });
The following settings can be used:
delay : false, // each letter will have different animation times speed : 300, // animation speed easing : 'jswing', // easing animation dir : 'leftright', // leftright - current goes left, new one goes right || rightleft - current goes right, new one goes left, overlay : false, // hover word is slided on top of the current word (just for the case when the hover word equals word) opacity : true // animate the letters opacity
We hope you liked this little experiment and find it useful!
Great use of lettering.js! Thanks for this tutorial ๐
Nice. It works really smooth. GJ !
so nice… it’s always like that with u! ๐
Very nice effect as always, runs very smooth in Chrome on Windows but not so in Firefox 3.6.17.
Great tutorial, the effect looks stunning.
Great !
Very beautiful !
So many jquery out there. This one rocks by the way. I worry about how this might display on mobile platforms.
Nice!!!
Like This ^_^
It’s really amazing how jQuery is helping bring so much of the awesome animation flourishes from Flash to more optimized platforms like the iPhone. Thanks for sharing!
Great!!
your work is amazing, thank you for this tutorial
Took a couple of refreshes to see the effect but it turned out to be great! Thanks for showing ๐
Awesome!
Mary Lou, do you know one method to make the animations run more smooth in Firefox ? or is a browser engine limitation?
very useful thanks!!
I noticed it’s not smooth on firefox 4 too. Works fine on Chrome and Opera, though.
Great plugin and thanks for letting us know about it.
Stunning as always! Runs smooth on Chromium & Firefox 4 on Ubuntu 11.04 and pretty nice on Android default web browser. Congratulations and many thanks for this beautiful tutorial.
Awesome effect.. and great tutorial too.
Awesome!!
THATS ABSOLUTELY GREAT!! I ALWAYS LOVE YOU MARY LOU! THIS IS SICK…MAKE BOUNCING TUTOTIAL ON HOVERRRR
Very nice effect. I will use it on some project for sure. Thanks!
Very nice,thank you! ๐
A really great effect! I will definitely utilize this in my upcoming projects! You guys never fail to amaze me!
omg very nice
Very nice, but I’m having trouble with 2 things:
On http://www.beautifullalaland.com/sub.html is a hidden menu (bottom left, click the +). The text there is jumbled but works fine after rolling over once. Any idea what’s wrong?
How to change easing? And what to do if I’d prefer no easing at all?
Keep up the good work!
Hi! I can’t access the site but I would guess that the style is not being applied to your words/text? The plugin is made to work with easing but you can choose a suitable effect: http://jqueryui.com/demos/effect/easing.html
Just add the setting when you call the plugin. Hope it helps, cheers, ML
Mary Lou, thanks for your help and the useful link. I think the problem has to do with a conflicting js, not CSS. I decided to drop the effect in that part of the site as it was too gimmicky.
Thanks again!
Great one ๐ So smooth
Very nice effect, your work is amazing. Thanks!:)
Thank you for sharing it Very nice..
Hi, great work, am new to this site, and I’ve been finding the tutorials and plugins on here to be a God sent.
I have a small problem, Instead of replacing the initial text with another text on data-hover, how can it be replaced with a div instead.
Basically what I want is for an element to slide and change to another element or div when hovered on. For example when a text ‘HOME’ is hovered on, it should slide away and reveal the site’s navigation.
Thanks. Keep up the great work, Hope to hear from you soon.
Thank u! Excellent effects!
Neat idea and very well written tutorial!
Great, high quality stuff as always. Thank’s a lot.
You can see effect like this in flash in http://lassepedersen.biz/ great website, now it’s possible to do it with jQuery!
Great ! thanks ๐
Small code, great effect. Thanks, Mary Lou!
Nice code just a little slower …
Thanks for share it!
Really is an amazing effect, but where use with phrases (words separated by spaces), the shows together without spaces, have any manner to modify this?
Woah, thanks! Looks amazing. Might use it in a upcoming project!
Nice plugin. Thanks!
I so like this Mary….. Awesome!
Wonderful post, very useful, love it, Thanks!
I love you Mary!!!
wow…really great..love you mary
1. Thank you!
2. How can we separate 2 words in this animated letters? It’s even possible?
… okej… i found the solution if we have 2 words. Just add CSS style: white-space: pre;
Example:
.sl_examples a{
margin:15px;
word-spacing: 5px;
white-space: pre;
}
Nice one ๐
oh.it’s great. really.thank you Mary Lou.
That is a SWEET effect.
so cool ,thank you
great Looks amazing.