Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stackoverflow style notification bar [duplicate]

Possible Duplicate:
Notification alert similar to how stackoverflow functions

The notification bar the top, which shows things like ' you earned xyz badge". How is it done? I am trying to create someting similar in my rails app. I use blueprint for my layout, it's a standard single column 950px layout, with everything from the header down to the footer is in a container div.

like image 266
badnaam Avatar asked Sep 16 '10 15:09

badnaam


1 Answers

You can do it pretty easily with a fixed position element that has a higher z-index than any other element on your page:

<div id="notification">
    You've earned xyz badge
</div>
<!-- rest of your site's markup -->

And with the following CSS:

#notification {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: yellow; 
}

Then it's just a matter of checking on page load if you need to create and display the #notification:

$(window).load(function(){
    if(showNotification){
        $('body').append(
            $('<div id="notification">You\'ve earned xyz badge</div>');
        );
    }
});
like image 196
Pat Avatar answered Nov 15 '22 00:11

Pat