In case of any error/warning from my server, I need to show and hide Top Notification Bar with absolute position - DIV.
I need to show this BAR only when the error occurs and hide it after say few seconds may be 10 sec, and with smooth effects?
How can one implement this in HTML, CSS/SCSS and Pure Javascript. NO Javscript Frameworks :(
<div id="app-notification-bar" class="app-notification-bar app-error-message"></div>
SCSS, prefix is app-
.#{$prefix}error-message {
font-family:Helvetica, Arial, sans-serif;
font-size:12px;
vertical-align:central;
color: #cc0000;
font-weight:bold;
}
.#{$prefix}notification-bar {
position: absolute;
z-index: 101;
top: 0;
left: 0;
right: 0;
background: #FFFFFF;
text-align: center;
line-height: 2.5;
overflow: hidden;
-webkit-box-shadow: 0 0 5px black;
-moz-box-shadow: 0 0 5px black;
box-shadow: 0 0 5px black;
}
@-webkit-keyframes slideDown {
0%, 100% { -webkit-transform: translateY(-50px); }
10%, 90% { -webkit-transform: translateY(0px); }
}
@-moz-keyframes slideDown {
0%, 100% { -moz-transform: translateY(-50px); }
10%, 90% { -moz-transform: translateY(0px); }
}
.cssanimations.csstransforms .#{$prefix}notification-bar {
-webkit-transform: translateY(-50px);
-webkit-animation: slideDown 2.5s 10.0s 1 ease forwards;
-moz-transform: translateY(-50px);
-moz-animation: slideDown 2.5s 10.0s 1 ease forwards;
}
JS
document.getElementById('app-notification-bar').innerHTML = wrnMsg;
setTimeout(function(){ document.getElementById('app-notification-bar').innerHTML = ''; }, 3000);