basti: Kann man ein JS alert schliessen, wenn es einen Click auf Ok verlangt?
Ich habs jetzt so gelöst, damit das Popup auch animiert verschwindet:
HTML
<div id="popup">gespeichert</div>
CSS
#popup {
display: none;
animation: fadeOut ease 1s;
-webkit-animation: fadeOut ease 1s;
-moz-animation: fadeOut ease 1s;
-o-animation: fadeOut ease 1s;
-ms-animation: fadeOut ease 1s;
animation-delay: 1s;
}
@keyframes fadeOut { 0% { opacity:1; } 100% { opacity:0; } }
@-moz-keyframes fadeOut { 0% { opacity:1; } 100% { opacity:0; } }
@-webkit-keyframes fadeOut { 0% { opacity:1; } 100% { opacity:0; } }
@-o-keyframes fadeOut { 0% { opacity:1; } 100% { opacity:0; } }
@-ms-keyframes fadeOut { 0% { opacity:1; } 100% { opacity:0; } }
JS
elem = document.getElementById("popup");
elem.style.display = "block";
setTimeout(function(){ elem.style.display = "none"; }, 1900);
Alles anzeigen
Beim #popup hab ich noch diverse Gestaltungen (border, shadow, color, position, etc).
Beim setTimeout sind die sec nicht 2000 sondern 1900 damit das div nicht nochmals kurz angezeigt wird, bevor es dann mit display: none unsichtbar wird.
Ich weiß nicht ob das elegant ist oder noch besser geht, aber es funktioniert.