I have created a pure CSS slider for images on my website. I used some code I found on stackoverflow, but I am experiencing a strange problem. In Safari, the images do not appear on my screen. The code works fine in all other browsers, but on Safari when I inspect the element, the image tag is correct and the dimensions of the image are correct. I can click the image url and view the image in the web inspector, and also when I open each image in a new tab. I have also tested the snippet alone in Safari, and it works correctly (See this fiddle https://jsfiddle.net/mvtyofup/)
Does anybody have a clue why Safari is preventing the images to show?
Here is my HTML
.slider {
margin: 10px auto;
width: 500px;
height: 320px;
overflow: hidden;
position: relative;
}
.photo {
position: absolute;
-webkit-animation: round 16s infinite;
opacity: 0;
width: 100%;
}
@-webkit-keyframes round {
25% {
opacity: 1;
}
40% {
opacity: 0;
}
}
img:nth-child(4) {
-webkit-animation-delay: 0s;
}
img:nth-child(3) {
-webkit-animation-delay: 4s;
}
img:nth-child(2) {
-webkit-animation-delay: 8s;
}
img:nth-child(1) {
-webkit-animation-delay: 12s;
}
<div class="slider">
<img class='photo' src="http://farm9.staticflickr.com/8241/8562523343_9bb49b7b7b.jpg" alt="" />
<img class='photo' src="http://farm9.staticflickr.com/8320/8035372009_7075c719d9.jpg" alt="" />
<img class='photo' src="http://farm9.staticflickr.com/8465/8113424031_72048dd887.jpg" alt="" />
<img class='photo' src="http://farm9.staticflickr.com/8517/8562729616_35b1384aa1.jpg" alt="" />
</div>
Update: When I removed the opacity:0 in the CSS for .photo, the images appear correctly and the slideshow works. There is a bit of undesired effect as there is no break in between slides any more. Maybe there is another way to get that working without opacity.