13. December 2008 by Janko in Tutorials | tags:

A few months ago I posted an article on creating message boxes. No question, you should really take care about it. But this time I want to make fun with it and add some animations using (you guess) jQuery.

The idea is more than simple. Let's animate message box that is being shown, and blow it away after we read it.

So this would be the HTML markup:

<div id="info">
    This is an animated info message. Do you see it? <a href="#" class="close">Now click here to make it go away!</a>
</div>

And nothing more. We'll need some CSS to meke it looks like something, just like in the article I mentioned earlier:

#info{
    border: 1px solid;
    margin: 10px 0px;
    padding:15px 10px 15px 50px;
    background-repeat: no-repeat;
    background-position: 10px center;
    position:relative;
    color: #00529B;
    background-color: #BDE5F8;
    background-image: url('info.png');
}

Cool. Now let's animate this. Although there are plenty of possibilities, I will show you just two. But I'd like you to experiment and try acheve various effects.

Blink effect

Ok, this one is pretty simple. The message will blink a few times just to let you know you should read it. Here is the code:

 $(document).ready(function(){
    $(".close").click(function(){
        $("#info").animate({left:"+=10px"}).animate({left:"-5000px"});
    });
    $("#info").fadeOut(800).fadeIn(800).fadeOut(400).fadeIn(400)
    .fadeOut(400).fadeIn(400);
});

View the demo

Nuge effect

Do you use MSN Messanger? You know how the chat window behaves when you send "nudge" to your colleague? We are going to do the same. Here is the code:

 $(document).ready(function(){
    $(".close").click(function(){
        $("#info").animate({left:"+=10px"}).animate({left:"-5000px"});
    });
    $("#info").animate({left:"+=5px"},40).animate({top:"+=5px"},40)
    .animate({top:"-=10px"},40).animate({left:"-=10px"},40)
    .animate({top:"+=5px"},40).animate({left:"+=5px"},40)
    .animate({left:"+=5px"},40).animate({top:"+=5px"},40)
    .animate({top:"-=10px"},40).animate({left:"-=10px"},40)
    .animate({top:"+=5px"},40).animate({left:"+=5px"},40);
});

View the demo

Those were my two samples. Got some other ideas?

If you liked this article why don't you share it:

Animate your message boxes with jQuery (via @jankowarpspeed) Share this on StumbleUpon Share this on delicious Share this on Digg Share this on Dzone Share this on DesignBump Send this to friend

Comments

Pingbacks and trackbacks

  1. Pingback from iliadobrev.com My Space In The Net » Blog Archive » Animate your message boxes with jQueryAnimate your message boxes with jQuery
  2. Trackback from DotNetKicks.com JankoAtWrapSpeed: Animate your message boxes with jQuery
  3. Pingback from tablosign.com Mensajes animados con jQuery — Tablosign
  4. Pingback from visual-blast.com Animated Message Boxes with jQuery
  5. Trackback from Design Bump Story on DesignBump.com
  6. Pingback from fabiomarasco.netsons.org Set di risorse jQuery | fabio marasco Web
  7. Pingback from newdisco.estupendos.net links for 2008-12-20 en newdisco
  8. Pingback from webair.it WebAir Blog » Blog Archive » 10 Easy Tutorial jQuery
  9. Pingback from boostmycode.com Boost My Code » CSS Javascript Message Box Usability jQuery » Message Boxes with jQuery (Appear/Disappear)
  10. Pingback from anieto2k.com Anima tus mensajes con jQuery | aNieto2K
  11. Pingback from marbioblog.com Set di risorse jQuery - marbio blog | Web 2.0, Internet e Informatica
  12. Pingback from sixrevisions.com 40 Exceptional jQuery Interface Techniques and Tutorials
  13. Pingback from e-szablony.eu 40 Exceptional jQuery Interface Techniques and Tutorials | e-szablony.eu
  14. Pingback from xeviox.com Howto create a simple message box in html (using css) » BenPas Blog
  15. Pingback from answerspluto.com list of urls - 5 « Answers Pluto
  16. Pingback from tripwiremagazine.com 60+ Must Have jQuery Toolbox | tripwire magazine
  17. Pingback from muliati.com 60+ Must Have jQuery Toolbox | The Muliati.Com goBlog
  18. Pingback from csshook.com 100 jQuery Samples | Resources
  19. Pingback from tripwiremagazine.com 95+ Exceptionally Useful jQuery Plugins, Tutorials and Cheat Sheets | tripwire magazine
  20. Pingback from huibit05.com 95+ Exceptionally Useful jQuery Plugins, Tutorials and Cheat Sheets | huibit05.com
  21. Pingback from millionaire.websitesuperhero.com Animate your message boxes with jQuery
  22. Pingback from 9tricks.com 40 Exceptional jQuery Interface Techniques and Tutorials | 9Tricks.Com - Tips - Tricks - Tutorials
  23. Pingback from vietphotoshop.wordpress.com 95+ Exceptionally Useful jQuery Plugins, Tutorials and Cheat Sheets « Photoshop.vn – Your Design Resource
  24. Pingback from jquery.wisdomplug.com jQuery Tutorial – Animate your message boxes with jQuery | jQuery Wisdom
  25. Pingback from slicingpsdtohtml.com 40 Exceptional jQuery Interface Techniques and Tutorials « PSD to HTML , Slicing PSD to HTML

Add comment

   
        Country flag
biuquote
Loading