Make Your Links (Hyperlinks) Even More Sexier

HyperLinkYou would have often seen various attempts to make hyperlink more beautiful. One of my personal favorite is to have little icons beside links to let you know where they link to.
Different icons for external links, pdfs, images, etc. etc. You can find the tutorial for such link over here.

In this post i'll tell you a technique using which you can make your links even more sexier.

Check out the demo first : View Demo

The Implementation of this effect is given in the following sections.

The HTML

<a class="link" href="#">Put Anything Here</a>

All you need is to add classname "link" to your hyperlinks.

The CSS

The only important class is to have the final class "a.link".

a:link,a:hover,a:active,a:visited{
	color:#59BAEF;
	text-decoration:none;
	white-space:nowrap;
}
a{
	outline:none;
}
a.link{
	background:transparent url(a-bg.png) no-repeat -81px bottom;
}

The Javascript : Mootools

window.addEvent('domready',function(){
	$$('a.link').each(function(a){
		a.setStyle('backgroundPosition', "-81px "+ (a.getSize().y-2) +"px");
		a.set('tween',{duration:600});
		a.addEvents({
			'mouseenter' : function(){
				a.tween('backgroundPosition', a.getSize().x + "px "+ (a.getSize().y-2) +"px");
			},
			'mouseleave' : function(){
				a.tween('backgroundPosition', "-81px "+ (a.getSize().y-2) +"px");
			}
		})
	})
})

The Javascript : jQuery

$(document).ready(function(){
    $('a.link').css('backgroundPosition', "-81px "+ ($(this).outerHeight()-2) +"px");
    $('a.link').bind('mouseenter',function(e){
        var a = $(this);
        a.animate({'backgroundPosition': a.outerWidth() + "px "+ (a.outerHeight()-2) +"px"},600);
    });
    $('a.link').bind('mouseleave',function(e){
        var a = $(this)
        a.animate({'backgroundPosition': "-81px "+ (a.outerHeight()-2) +"px"},600);
    });
})

Image Used

This effect is just a demo of the possibilities. I would love to here your own implementations.

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Other Posts which you may like:

22 responses to “Make Your Links (Hyperlinks) Even More Sexier”

  1. tasser

    Cool. javascript is getting flash ier by the day.

  2. Shurandy Thode

    Great! Thanks for sharing.

  3. Praveen

    First of all thanks for sharing your experience.
    I tried with your code but my DOM element is not getting ready.
    I am sure my js file is calling (as i checked with my other function).

    Thanks

  4. 10 Ways to animate your hyperlinks

    [...] 1. Make Your Links (Hyperlinks) Even More Sexier [...]

  5. DJ NightLife

    I’m getting “window.addEvent” is not a function in Javascript debugger… Would love to get a wordpress plugin to toggle between different effects !

  6. DJ NightLife

    I downloaded the motools .js and linked it in my tag… still not working! As for JQuery, what file do I need to include?

  7. DJ NightLife

    Now I’m getting “$ is not a function” from the .js file :(

  8. DJ NightLife

    Thanks a lot, it’s hot!

  9. DJ NightLife

    How can you add the effect for multiple classes ?

  10. DJ NightLife
  11. DJ NightLife

    (Also notice it’s only working on the home page for some reasons, if you are in post, the effect is not appearing…)

  12. DJ NightLife

    Just noticed it’s not working on IE8, is it just me ?

  13. Howtoblogformoney

    Nice share. let me try it—though I am not as tech savvy as your other readers here.

  14. sebestiraj

    its very nice and i like it so much. but i can’t Understand it can u mail the explanations for this sexier link creation and thumb nail link creation

Leave a Reply

Subscribe Me

Google Custom Search