Slider html5/css display 2 row of images instead one - css

Im trying to insert images in slider. For now only 5 demonstrates in 1 row, but i got 7 and the rest demonstrates in second row. Looks ugly. I know that major changes probably in css , but i have no idea what i need to change.
Thank you for response.
css:
#keyframes slidy {
0% { left: 0%; }
20% { left: 0%; }
25% { left: -20%; }
45% { left: -30%; }
50% { left: -40%; }
70% { left: -50%; }
75% { left: -80%; }
95% { left: -90%; }
100% { left: -100%; }
}
body, figure {
margin: 0;
font-family:
"HelveticaNeue-Light",
"Helvetica Neue Light",
"Helvetica Neue",
Helvetica, Arial,
"Lucida Grande",
sans-serif;
font-weight: 50;
font-size: 15px;
}
div#captioned-gallery {
width: 100%; overflow: hidden;
}
figure.slider {
position: relative; width: 300%;
font-size: 0; animation: 30s slidy infinite;
}
figure.slider figure {
width: 20%; height: auto;
display: inline-block; position: inherit;
}
figure.slider img { width: 20%; height: auto; }
figure.slider figure figcaption {
position: absolute; bottom: 0;
background: rgba(0,0,0,0.3);
color: #fff; width: 100%;
font-size: 1rem; padding: .6rem;
}
Image of Resin Toy Cars
Image of Cat Statuettes

Here's one I made earlier ;) You can ignore the transforms that was an effect for another transition. Here is a fiddle for you http://jsfiddle.net/RachGal/o6haapvt/
* {
margin: 0;
padding: 0;
}
.pic-wrapper {
position: absolute;
width: 100%;
height: 100%;
overflow:hidden;
}
figure {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity:0;
/*animation*/
animation: slideShow 42s linear infinite 0s;
-o-animation: slideShow 42s linear infinite 0s;
-moz-animation: slideShow 42s linear infinite 0s;
-webkit-animation: slideShow 42s linear infinite 0s;
}
.pic-1 {
animation-delay: 0s;
-o-animation-delay: 0s;
-moz-animation-delay: 0s;
-webkit-animation-delay: 0s;
background: url(http://www.rachelgallen.com/images/daisies.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.pic-2 {
animation-delay: 6s;
-o-animation-delay: 6s;
-moz-animation-delay: 6s;
-webkit-animation-delay: 6s;
background: url(http://www.rachelgallen.com/images/snowdrops.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.pic-3 {
animation-delay: 12s;
-o-animation-delay: 12s;
-moz-animation-delay: 12s;
-webkit-animation-delay: 12s;
background: url(http://rachelgallen.com/images/mountains.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.pic-4 {
animation-delay: 18s;
-o-animation-delay: 18s;
-moz-animation-delay: 18s;
-webkit-animation-delay: 18s;
background: url(http://www.rachelgallen.com/images/purpleflowers.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.pic-5 {
animation-delay: 24s;
-o-animation-delay: 24s;
-moz-animation-delay: 24s;
-webkit-animation-delay: 24s;
background: url(http://www.rachelgallen.com/images/yellowflowers.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.pic-6 {
animation-delay: 30s;
-o-animation-delay: 30s;
-moz-animation-delay: 30s;
-webkit-animation-delay: 30s;
background: url(http://www.rachelgallen.com/images/daisies.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.pic-7 {
animation-delay: 36s;
-o-animation-delay: 36s;
-moz-animation-delay: 36s;
-webkit-animation-delay: 36s;
background: url(http://www.rachelgallen.com/images/snowdrops.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
figure figcaption {
position: absolute;
bottom: 0;
text-align:center;
background: rgba(0, 0, 0, 0.3);
color: #fff;
width: 100%;
font-size: 1rem;
padding: .6rem;
}
/* keyframes*/
#keyframes slideShow {
0% {
opacity: 0.5;
transform:scale(1);
-ms-transform:scale(1);
}
4% {
opacity: 1
}
24% {
opacity: 1;
}
28% {
opacity: 0;
}
100% {
opacity: 0;
transform:scale(1);
-ms-transform:scale(1);
}
}
#-o-keyframes slideShow {
0% {
opacity: 0.5;
-o-transform:scale(1);
}
4% {
opacity: 1
}
24% {
opacity: 1;
}
28% {
opacity: 0;
}
100% {
opacity: 0;
-o-transform:scale(1);
}
}
#-moz-keyframes slideShow {
0% {
opacity: 0.5;
-moz-transform:scale(1);
}
4% {
opacity: 1
}
24% {
opacity: 1;
}
28% {
opacity: 0;
-moz-transform:scale(1.1);
}
100% {
opacity: 0;
-moz-transform:scale(1);
}
}
#-webkit-keyframes slideShow {
0% {
opacity: .5;
-webkit-transform:scale(1);
}
4% {
opacity: 1
}
24% {
opacity: 1;
}
28% {
opacity: 0;
}
100% {
opacity: 0;
-webkit-transform:scale(1);
}
}
<div class="pic-wrapper">
<figure class="pic-1">
<figcaption>Daisies</figcaption>
</figure>
<figure class="pic-2">
<figcaption>Snowdrops</figcaption>
</figure>
<figure class="pic-3">
<figcaption>Mountains</figcaption>
</figure>
<figure class="pic-4">
<figcaption>Purple Flowers</figcaption>
</figure>
<figure class="pic-5">
<figcaption>Yellow Flowers</figcaption>
</figure>
<figure class="pic-6">
<figcaption>Daisies Again</figcaption>
</figure>
<figure class="pic-7">
<figcaption>Snowdrops Again</figcaption>
</figure>
</div>

Related

Slider with zoom and movement effect

I’m trying to build a css only Slider with zoom effect.
The thing I’m not able to do is to difference the zoom from one slide to the other. For example I would like the first slide to have the current zoom effect but going slowly from right to left, the second from left to right and the third from top to bottom.
Any help?
Here is the Jsfiddle
<div class="pic-wrapper">
<figure class="pic-1"></figure>
<figure class="pic-2"></figure>
<figure class="pic-3"></figure>
<figure class="pic-4"></figure>
</div>
You can accomplish this by setting the property background-position in your animation.
I added background-position: 0px 0px; to slideShow { 0% {} and background-position: -400px 0px; to slideShow { 100% {}.
Now the image moves slowly to the left.
* {
margin: 0;
padding: 0;
}
.pic-wrapper {
position: absolute;
width: 100%;
height: 100%;
overflow: hidden;
}
figure {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
/*animation*/
animation: slideShow 24s linear infinite 0s;
-o-animation: slideShow 24s linear infinite 0s;
-moz-animation: slideShow 24s linear infinite 0s;
-webkit-animation: slideShow 24s linear infinite 0s;
}
figurecaption {
position: absolute;
top: 50%;
left: 50%;
color: #fff;
}
.pic-1 {
opacity: 1;
background: url(https://c.slashgear.com/wp-content/uploads/2018/07/4223-SUZUKIJIMNYTHEONE-AND-ONLYSMALLLIGHTWEIGHT4WDVEHICLE-980x620.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.pic-2 {
animation-delay: 6s;
-o-animation-delay: 6s;
-moz--animation-delay: 6s;
-webkit-animation-delay: 6s;
background: url(https://c.slashgear.com/wp-content/uploads/2018/07/4223-SUZUKIJIMNYTHEONE-AND-ONLYSMALLLIGHTWEIGHT4WDVEHICLE-980x620.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.pic-3 {
animation-delay: 12s;
-o-animation-delay: 12s;
-moz--animation-delay: 12s;
-webkit-animation-delay: 12s;
background: url(https://c.slashgear.com/wp-content/uploads/2018/07/4223-SUZUKIJIMNYTHEONE-AND-ONLYSMALLLIGHTWEIGHT4WDVEHICLE-980x620.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.pic-4 {
animation-delay: 18s;
-o-animation-delay: 18s;
-moz--animation-delay: 18s;
-webkit-animation-delay: 18s;
background: url(https://c.slashgear.com/wp-content/uploads/2018/07/4223-SUZUKIJIMNYTHEONE-AND-ONLYSMALLLIGHTWEIGHT4WDVEHICLE-980x620.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
/* keyframes*/
#keyframes slideShow {
0% {
background-position: 0px 0px;
opacity: 0;
transform:scale(1);
-ms-transform:scale(1);
}
5% {
opacity: 1
}
25% {
opacity: 1;
}
30% {
opacity: 0;
transform:scale(1.1);
-ms-transform:scale(1.1);
}
100% {
background-position: -400px 0px;
opacity: 0;
transform:scale(1);
-ms-transformm:scale(1);
}
}
#-o-keyframes slideShow {
0% {
background-position: 0px 0px;
opacity: 0;
-o-transform:scale(1);
}
5% {
opacity: 1
}
25% {
opacity: 1;
}
30% {
opacity: 0;
-o-transform:scale(1.1);
}
100% {
background-position: -400px 0px;
opacity: 0;
-o-transformm:scale(1);
}
}
#-moz-keyframes slideShow {
0% {
background-position: 0px 0px;
opacity: 0;
-moz-transform:scale(1);
}
5% {
opacity: 1
}
25% {
opacity: 1;
}
30% {
opacity: 0;
-moz-transform:scale(1.1);
}
100% {
background-position: -400px 0px;
opacity: 0;
-moz-transformm:scale(1);
}
}
#-webkit-keyframes slideShow {
0% {
background-position: 0px 0px;
opacity: 0;
-webkit-transform:scale(1);
}
5% {
opacity: 1
}
25% {
opacity: 1;
}
30% {
opacity: 0;
-webkit-transform:scale(1.1);
}
100% {
background-position: -400px 0px;
opacity: 0;
-webkit-transformm:scale(1);
}
}
<div class="pic-wrapper">
<figure class="pic-1"></figure>
<figure class="pic-2"></figure>
<figure class="pic-3"></figure>
<figure class="pic-4"></figure>
</div>
JSFiddle: https://jsfiddle.net/53gpxtk1/23/

CSS Slideshow with wrong timing of last image

I have a little problem with css3 slideshow. I am trying to run this https://www.cssscript.com/pure-css-css3-slideshow-with-image-panning-and-zooming-effect/ with 10 pictures.
And my problem is that all slides don't have same duration. Now my nine slides goes correct for 5 seconds each. But there is problem that last tenth image stops for much more time. I think over 10 seconds.
My source code is same as in example in link. Only changes are:
animation: slideShow 50s linear infinite 0s;
-o-animation: slideShow 50s linear infinite 0s;
-moz-animation: slideShow 50s linear infinite 0s;
-webkit-animation: slideShow 50s linear infinite 0s;
.pic-2 {
animation-delay: 5s;
-o-animation-delay: 5s;
-moz--animation-delay: 5s;
-webkit-animation-delay: 5s;
and same for pic-3 with 10s ..... pic-10 with 45s
Is it possible to fix it?
Thanks for answers
Edit: Now my code in body for overall duration 40s is and it still not working:
<div class="pic-wrapper">
<figure class="pic-1"></figure>
<figure class="pic-2"></figure>
<figure class="pic-3"></figure>
<figure class="pic-4"></figure>
<figure class="pic-5"></figure>
<figure class="pic-6"></figure>
<figure class="pic-7"></figure>
<figure class="pic-8"></figure>
<figure class="pic-9"></figure>
<figure class="pic-10"></figure>
</div>
<style>
* {
margin: 0;
padding: 0;
}
.pic-wrapper {
position: absolute;
width: 100%;
height: 100%;
overflow: hidden;
}
figure {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
/*animation*/
animation: slideShow 40s linear infinite 0s;
-o-animation: slideShow 40s linear infinite 0s;
-moz-animation: slideShow 40s linear infinite 0s;
-webkit-animation: slideShow 40s linear infinite 0s;
}
figurecaption {
position: absolute;
top: 50%;
left: 50%;
color: #fff;
}
.pic-1 {
opacity: 1;
background: url(pic1.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.pic-2 {
animation-delay: 4s;
-o-animation-delay: 4s;
-moz--animation-delay: 4s;
-webkit-animation-delay: 4s;
background: url(pic2.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.pic-3 {
animation-delay: 8s;
-o-animation-delay: 8s;
-moz--animation-delay: 8s;
-webkit-animation-delay: 8s;
background: url(pic3.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.pic-4 {
animation-delay: 12s;
-o-animation-delay: 12s;
-moz--animation-delay: 12s;
-webkit-animation-delay: 12s;
background: url(pic4.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.pic-5 {
animation-delay: 16s;
-o-animation-delay: 16s;
-moz--animation-delay: 16s;
-webkit-animation-delay: 16s;
background: url(pic5.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.pic-6 {
animation-delay: 20s;
-o-animation-delay: 20s;
-moz--animation-delay: 20s;
-webkit-animation-delay: 20s;
background: url(pic6.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.pic-7 {
animation-delay: 24s;
-o-animation-delay: 24s;
-moz--animation-delay: 24s;
-webkit-animation-delay: 24s;
background: url(pic7.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.pic-8 {
animation-delay: 28s;
-o-animation-delay: 28s;
-moz--animation-delay: 28s;
-webkit-animation-delay: 28s;
background: url(pic8.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.pic-9 {
animation-delay: 32s;
-o-animation-delay: 32s;
-moz--animation-delay: 32s;
-webkit-animation-delay: 32s;
background: url(pic9.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.pic-10 {
animation-delay: 36s;
-o-animation-delay: 36s;
-moz--animation-delay: 36s;
-webkit-animation-delay: 36s;
background: url(pic10.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
/* keyframes*/
#keyframes slideShow {
0% {
opacity: 0;
transform:scale(1);
-ms-transform:scale(1);
}
4% {
opacity: 1
}
24% {
opacity: 1;
}
28% {
opacity: 0;
transform:scale(1.1);
-ms-transform:scale(1.1);
}
100% {
opacity: 0;
transform:scale(1);
-ms-transformm:scale(1);
}
}
#-o-keyframes slideShow {
0% {
opacity: 0;
-o-transform:scale(1);
}
4% {
opacity: 1
}
24% {
opacity: 1;
}
28% {
opacity: 0;
-o-transform:scale(1.1);
}
100% {
opacity: 0;
-o-transformm:scale(1);
}
}
#-moz-keyframes slideShow {
0% {
opacity: 0;
-moz-transform:scale(1);
}
4% {
opacity: 1
}
24% {
opacity: 1;
}
28% {
opacity: 0;
-moz-transform:scale(1.1);
}
100% {
opacity: 0;
-moz-transformm:scale(1);
}
}
#-webkit-keyframes slideShow {
0% {
opacity: 0;
-webkit-transform:scale(1);
}
4% {
opacity: 1
}
24% {
opacity: 1;
}
28% {
opacity: 0;
-webkit-transform:scale(1.1);
}
100% {
opacity: 0;
-webkit-transformm:scale(1);
}
}
</style>

Little trouble with css

Hello i have some issues with my code because animation won't work here's my code:
background-image:url(industry2.jpg);
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
border:1px solid red;
-webkit-animation: fadein 2s ease-in ;
-moz-animation: fadein 2s ease-in ;
animation: fadein 2s ease-in ;
width:500px;
height:200px;
background-repeat: no-repeat;
background-position: left top;
padding-top:68px;
position:absolute;
top:2700px;
left:1300px;
#keyframes fadein {
from { opacity: 0; }
to { opacity: 1; }
you see i don't get animation working and i don't know what to do...
You had not closed the #keyframes. I have removed the left and top position for visibility purpose.
.container {
background-image: url("http://via.placeholder.com/500x200");
background-size: cover;
border: 1px solid red;
animation: fadein 2s ease-in;
width: 500px;
height: 200px;
background-repeat: no-repeat;
background-position: left top;
padding-top: 68px;
position: absolute;
}
#keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
<div class="container">Hello</div>

Why doesn't this slideshow work in Firefox?

I have created a slideshow that works perfect in Chrome, however, when I open the website in Firefox the slideshow doesn't show up at all. I have tried out some suggestions on solutions I found here on StackOverflow but nothing has worked so far.
Any ideas why this is happening?
Press on 'Run the code snippet' below to see the code in action. If your using Chrome everything should work fine, if Firefox it won't work at all...
.slide-box {
position: absolute;
z-index: 1;
height: 100vh;
width: 100%;
}
.slide-box .slideshow {
background-color: #000000;
width: 100wv;
height: 100vh;
}
.slide-box .slideshow .background {
position: absolute; /* For overlapping of page 1*/
width: 100%;
height: 90vh;
bottom: 0;
left: 0;
opacity: 0;
z-index: 0;
-webkit-backface-visibility: hidden;
-webkit-animation: imageAnimation 48s linear infinite 0s;
-moz-animation: imageAnimation 48s linear infinite 0s;
-o-animation: imageAnimation 48s linear infinite 0s;
-ms-animation: imageAnimation 48s linear infinite 0s;
animation: imageAnimation 48s linear infinite 0s;
-webkit-filter: grayscale(10%);
filter: grayscale(10%);
}
.slide-box .slideshow .background:nth-child(1) {
background: url(https://images5.alphacoders.com/330/330145.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.slide-box .slideshow .background:nth-child(2) {
background: url(https://hdwallsource.com/img/2014/4/background-wallpaper-22922-23558-hd-wallpapers.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
-webkit-animation-delay: 8s;
-moz-animation-delay: 8s;
-o-animation-delay: 8s;
-ms-animation-delay: 8s;
animation-delay: 8s;
}
.slide-box .slideshow .background:nth-child(3) {
background: url(https://www.walldevil.com/wallpapers/a89/wallpapers-backgrounds-scenic-desktop-background-landscape-landscapes-nature-roads-road.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
-webkit-animation-delay: 16s;
-moz-animation-delay: 16s;
-o-animation-delay: 16s;
-ms-animation-delay: 16s;
animation-delay: 16s;
}
.slide-box .slideshow .background:nth-child(4) {
background: url(https://images5.alphacoders.com/330/330145.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
-webkit-animation-delay: 24s;
-moz-animation-delay: 24s;
-o-animation-delay: 24s;
-ms-animation-delay: 24s;
animation-delay: 24s;
}
.slide-box .slideshow .background:nth-child(5) {
background: url(https://hdwallsource.com/img/2014/4/background-wallpaper-22922-23558-hd-wallpapers.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
-webkit-animation-delay: 32s;
-moz-animation-delay: 32s;
-o-animation-delay: 32s;
-ms-animation-delay: 32s;
animation-delay: 32s;
}
.slide-box .slideshow .background:nth-child(6) {
background: url(https://www.walldevil.com/wallpapers/a89/wallpapers-backgrounds-scenic-desktop-background-landscape-landscapes-nature-roads-road.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
-webkit-animation-delay: 40s;
-moz-animation-delay: 40s;
-o-animation-delay: 40s;
-ms-animation-delay: 40s;
animation-delay: 40s;
}
/* Animation for the slideshow images */
#-webkit-keyframes imageAnimation {
0% { opacity: 0;
-webkit-animation-timing-function: ease-in; }
8% { opacity: 1;
-webkit-animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0 }
100% { opacity: 0 }
}
#-moz-keyframes imageAnimation {
0% { opacity: 0;
-moz-animation-timing-function: ease-in; }
8% { opacity: 1;
-moz-animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0 }
100% { opacity: 0 }
}
#-o-keyframes imageAnimation {
0% { opacity: 0;
-o-animation-timing-function: ease-in; }
8% { opacity: 1;
-o-animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0 }
100% { opacity: 0 }
}
#-ms-keyframes imageAnimation {
0% { opacity: 0;
-ms-animation-timing-function: ease-in; }
8% { opacity: 1;
-ms-animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0 }
100% { opacity: 0 }
}
#keyframes imageAnimation {
0% { opacity: 0;
animation-timing-function: ease-in; }
8% { opacity: 1;
animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0 }
100% { opacity: 0 }
}
<div class="slide-box">
<div class="slideshow">
<div class="background"></div>
<div class="background"></div>
<div class="background"></div>
<div class="background"></div>
<div class="background"></div>
<div class="background"></div>
</div>
</div>

Full background image with fade effect

.crossfade > div {
animation: imageAnimation 30s linear infinite 0s;
backface-visibility: hidden;
background-size: cover;
background-position: center center;
color: transparent;
height: 100%;
left: 0px;
opacity: 0;
position: fixed;
top: 0px;
width: 100%;
z-index: 0;
}
.crossfade {
height: 500px;
}
#fade1{
background-image: url('../images/taxi.jpg');
}
#fade2 {
animation-delay: 6s;
background-image: url('../images/default.jpg');
}
#fade3 {
animation-delay: 12s;
background-image: url('../images/neuroBG.JPG');
}
#fade4 {
animation-delay: 18s;
background-image: url('../images/new4.jpeg');
}
#fade5 {
animation-delay: 24s;
background-image: url('../images/new3.jpg');
}
#fade6 {
animation-delay: 30s;
background-image: url('../images/new1.jpg');
}
#fade7 {
animation-delay: 36s;
background-image: url('../images/new2.jpeg');
}
<div class="crossfade">
<div id="fade1"></div>
<div id="fade2"></div>
<div id="fade3"></div>
<div id="fade4"></div>
<div id="fade5"></div>
<div id="fade6"></div>
<div id="fade7"></div>
</div>
I will like to make a background image fade in and out just like this website www.flitways.com
I have tried replicate this but the images are not fading in properly. I just feel that there is something missing. Will appreciate any help as regards this. Thanks.
To make images fade in and out properly, one need to calculate percentages and timings for it to look good, as done below, or simply give each image a #keyframes rule of their own.
For "n" images you must define:
a=presentation time for one image
b=duration for cross fading
Total animation-duration is of course t=(a+b)*n
animation-delay = t/n or = a+b
Percentage for keyframes:
0%
a/t*100%
(a+b)/t*100% = 1/n*100%
100%-(b/t*100%)
100%
Src: http://css3.bradshawenterprises.com/cfimg/
.crossfade > div {
animation: imageAnimation 8s linear infinite;
backface-visibility: hidden;
background-size: cover;
background-position: center center;
color: transparent;
height: 100%;
left: 0;
position: fixed;
top: 0;
width: 100%;
}
.crossfade {
height: 500px;
}
#keyframes imageAnimation {
0% {
opacity:1;
}
17% {
opacity:1;
}
25% {
opacity:0;
}
92% {
opacity:0;
}
100% {
opacity:1;
}
}
.crossfade div:nth-of-type(1) {
background-image: url(http://placehold.it/200/f00);
animation-delay: 6s;
}
.crossfade div:nth-of-type(2) {
background-image: url(http://placehold.it/200/0b0);
animation-delay: 4s;
}
.crossfade div:nth-of-type(3) {
background-image: url(http://placehold.it/200/00f);
animation-delay: 2s;
}
.crossfade div:nth-of-type(4) {
background-image: url(http://placehold.it/200/ff0);
animation-delay: 0;
}
<div class="crossfade">
<div></div>
<div></div>
<div></div>
<div></div>
</div>

Resources