I made fading slideshow in CSS3. Now I must insert it in a div container in such a way that the slideshow has width 100% of the parent, and appropriate height. If it was a single image I can easily do this:
<img src='url' style='border: 4px solid #dedede; width: 100%; margin-bottom: 3%;' />";
But in order to work the slideshow needs all the images to overlap, and the only way I'm able to find out is to position those images absolute. When I do this, the div container no longer stretches around my images, so whatever I do I end up either with stretched image or with too big or too small container when resizing the page. The only workaround I see is to use like 10-15 media queries to resize my div's height for each page width and keep it's height slightly bigger than the slideshow. But aren't there better solutions, because that's a bad one.. And here's my slideshow code:
.slide{position: relative;}
.slide figure{
border: 4px solid #dedede;
margin: 0;
position: absolute;
opacity: 0;
}
.slide figure:nth-child(1) {animation: xfade 20s 0s infinite;}
.slide figure:nth-child(2) {animation: xfade 20s 6s infinite;}
.slide figure:nth-child(3) {animation: xfade2 20s 12s infinite;}
@keyframes xfade{
0%{opacity: 0;}
10%{opacity: 1;}
30%{opacity: 1;}
40%{opacity: 0;}
}
@keyframes xfade2{
0%{opacity: 0;}
10%{opacity: 1;}
40%{opacity: 1;}
50%{opacity: 0;}
}
After our comment discussion, you ended up with 5 possible solutions (none perfect unfortunately since they require processing):
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.