Here is something that provided real food for thought :)
I had to apply 2 animations to change the opacity: xfade-25pct and xfade-50pct . Both play only 2 times, gradually disappearing after 25% and 50% of the animation. And additional show animation to make the 3rd image a stick after 2 animation cycles, with the necessary animation-fill-mode: forwards; .
The trick to opacity is this: you need to divide the animation into 4 quarters. If you want, you can change the overall duration of the animation from 60s to a multiple of 4 and adjust the delay. The third delay in the animation is the double 2nd.
----#----
Feel free to ask. Hope this helps you.
var s = 0, c = 1; window.setInterval(function() { s++; document.querySelector('DIV').innerHTML = s; if (s == 15 && c <= 2 || s == 30) { if (s == 30) { c = 1; } else { c++; } s = 0; } }, 1000);
ul { list-style: none; margin: 0; padding: 0; position: relative; } li { position: absolute; opacity: 0; } li { animation: xfade-25pct 60s 2; } li:nth-child(2) { animation-delay: 15s; } li:nth-child(3) { animation-delay: 30s, 120s; animation-name: xfade-50pct, show; animation-duration: 60s, 1s; animation-iteration-count: 2, 1; animation-fill-mode: forwards; } @keyframes xfade-25pct { 0% { opacity: 0; } 2%, 25% { opacity: 1; } 27% { opacity: 0; } } @keyframes xfade-50pct { 0% { opacity: 0; } 2%, 50% { opacity: 1; } 52% { opacity: 0; } } @keyframes show { 0%, 100% { opacity: 1; } }
<DIV></DIV> <ul> <li><img width="500" height="500" src="https://www.noao.edu/image_gallery/images/d2/pelican_500.jpg" alt="pic1"></li> <li><img width="500" height="500" src="http://whc.unesco.org/uploads/thumbs/news_920-500-500-20151015155516.jpg" alt="pic2"></li> <li><img width="500" height="500" src="https://i.pinimg.com/736x/4c/17/65/4c176537aee906de294138c3bac5b8f5--merry-christmas-love-coffee-aroma.jpg" alt="pic3"></li> </ul>
source share