Ich habe ein Modal, um Bilder zu sehen, die die Animation nur das erste Mal auf Firefox spielt. Wenn ich es zum ersten Mal öffne, funktioniert es, aber wenn ich es zum zweiten Mal öffne, spielt es die Animation nicht ab. Es funktioniert auf Chrome tho.Modal spielt keine Animation zweimal auf Firefox
HTML
<img src="https://s-media-cache-ak0.pinimg.com/236x/e8/2e/cc/e82ecc7ea98248bfa8161dcfcef2974a.jpg" id="postimage"></img>
<div id="myModal" class="modal">
<span class="close" onclick="document.getElementById('myModal').style.display='none'">×</span>
<img class="modal-content" id="modalImage">
</div>
CSS
.modal {
display: none;
position: fixed;
z-index: 999999;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0,0,0,0.8);
}
#postimage:hover {
opacity: 0.8;
cursor: pointer;
}
.modal-content {
display: block;
width: 100%;
margin: auto;
max-width: 720px;
}
@-webkit-keyframes fadeIn {
from {opacity:0.0}
to {opacity:1}
}
@keyframes fadeIn {
from {opacity:0.0}
to {opacity:1}
}
.modal-content {
-webkit-animation-name: fadeIn;
-webkit-animation-duration: 1.8s;
animation-name: fadeIn;
animation-duration: 1.8s;
}
.close {
position: absolute;
top: 50px;
right: 50px;
color: #e3e3e3;
font-size: 40px;
font-weight: bold;
transition: 0.3s;
}
.close:hover,
.close:focus {
cursor: pointer;
color: #787878;
}
JS
var modal = document.getElementById('myModal');
var img = document.getElementById('postimage');
var modalImg = document.getElementById("modalImage");
img.onclick = function(){
modal.style.display = "block";
modalImg.src = this.src;
}
var span = document.getElementsByClassName("close")[0];
span.onclick = function() {
modal.style.display = "none";
}
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
@kodecount für welchen Zweck? – Mirakurun
@kodecount Nun, es funktioniert nicht. Ich habe es versucht. – Mirakurun
Das Problem ist, es wird wieder auf Firefox animieren, wenn es nicht vollständig animiert war. Wenn die Animation zu Ende ging, wird sie nicht erneut animiert. – Mirakurun