Demo Link :- http://jsfiddle.net/rahuldass/mj3UQ/7/
Make it the first <div>
under the <body>
tag.
HTML
<div id="notify"></div>
<div id="content">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</div>
CSS
#notify {
position:relative;
width:100%;
background-color: tomato;
height:30px;
color:white;
display:none;
text-align:center;
padding:12px;
font-size:1em;
line-height:1em;
font-family: Arial, sans-serif;
border:1px solid red;
cursor:pointer;
}
p {
margin: 20px;
}
JavsScript
$('#notify').click(function() {
$(this).slideUp().empty();
});
$(function(){
$('#notify').html('Welcome to the test page!').slideDown();
});
Multiple Notification
If you want multiple notifications, change #notify to .notify and stack em up. Something like this:
Demo Link :- http://jsfiddle.net/rahuldass/6j8Lk/3/
HTML
<div id="content">
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</div>
CSS
.notify {
position:relative;
width:100%;
background-color:tomato;
height:30px;
color:white;
display:none;
text-align:center;
padding:5px;
font-size:1em;
line-height:1em;
font-family: Arial, sans-serif;
border:1px solid red;
cursor:pointer;
}
p {
font-family:Arial, sans-serif;
margin:20px;
}
JavsScript
$('.notify').live('click',function() {
$(this).slideUp('fast',function(){$(this).remove();});
});
$(function(){
notify('You have earned the JQuery badge!');
notify('You have earned the Super Awesome badge!');
});
function notify(msg) {
$('<div/>').prependTo('body').addClass('notify').html(msg).slideDown();
}