Skip to content

Instantly share code, notes, and snippets.

@kellishaver
Created February 13, 2010 19:22
Show Gist options
  • Save kellishaver/303638 to your computer and use it in GitHub Desktop.
Save kellishaver/303638 to your computer and use it in GitHub Desktop.
javascript/css for floating flash notice
#flash_notice {
width:400px;
padding:10px;
background:#dbffca;
color:#060;
height:30px;
line-height:30px;
border:1px solid #060;
font-family:arial, helvetica, sans-serif;
font-size:12pt;
margin-top:30px;
}
# dead simple, but just so I don't lose it...
function flash_notice(message) {
notice = $('<div></div>').attr('id', 'flash_notice').html(message);
notice.css('position', 'absolute');
notice.css('z-index', 1050);
$('body').append(notice.hide());
notice.css('left', ($('body').width() / 2) - (notice.width() / 2)) + 'px';
notice.css('top', $(window).scrollTop() + 'px');
notice.fadeIn();
function remove_notice() { notice.fadeOut(function() { notice.remove() }); }
setTimeout(remove_notice, 3000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment