How can I make a Twitter style alert stick to the top of the window?

Posted by Robert Robb on Stack Overflow See other posts from Stack Overflow or by Robert Robb
Published on 2010-04-11T08:40:58Z Indexed on 2010/04/11 8:43 UTC
Read the original article Hit count: 286

Filed under:
|
|
|

There is an excellent code example on how to make nice jQuery Twitter style alerts here:

http://blog.codecrate.com/2009/10/twitter-style-alerts-in-rails.html

$(function () {
  var alert = $('.alert');
  if (alert.length > 0) {
    alert.show().animate({height: alert.outerHeight()}, 200);

    window.setTimeout(function() {
      alert.slideUp();
    }, 3000);
  }
});

However, one thing that the code doesn't include is functions to stick the alert div to the top of the window, no matter how far down the page the user has scrolled.

I have found a few examples but nothing seems to play nice with this existing code.

Any ideas?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about html