I am building a responsive one-page website using multiple divs which scale to the height and width of the user's browser. I would like to have multiple background images crossfade into one other in an infinite loop within one of the divs on the website. I have attempted to follow this tutorial: http://css3.bradshawenterprises.com/cfimg/ to the best of my ability, but have been unable to adapt it to my specific needs. I believe I am missing a piece of code from the tutorial that is integral to this system, but I can't for the life of me understand which parts I must and which parts I mustn't implement in order for this to work in this case. (In part due to my nooby-ness and in part due to the fact that the tutorial is oddly segmented.)
I am a total noob to Web Dev, so please forgive me (and correct me) if my code is terribly wrong.
<html>
<body>
<div id="home" class="panel">
<div class="inner">
<div id="backgroundchange">
<div id="back1"></div>
<div id="back2"></div>
<div id="back3"></div>
<div id="back4"></div>
<div id="back5"></div>
</div>
</div>
</div>
<body>
<html>
<!--Div Formatting-->
html, body {
height: 100%;
margin: 0;
}
.panel {
font-family: "Source Sans Pro", Helvetica, Arial, sans-serif;
color: white;
height: 100%;
min-width: 100%;
text-align: center;
display: table;
margin: 0;
background: #1c1c1c;
padding: 0 0;
}
.panel .inner {
display: table-cell;
vertical-align: middle;
}
<!--Background Animation-->
#backgroundchange.backgroundimg {
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
transition: background-image 1s ease-in-out;
}
#back1 {
background: url(../img/Back1.png) no-repeat center center fixed;
}
#back2 {
background: url(../img/Back2.png) no-repeat center center fixed;
}
#back3 {
background: url(../img/Back3.png) no-repeat center center fixed;
}
#back4 {
background: url(../img/Back4.png) no-repeat center center fixed;
}
@keyframes cf4FadeInOut {
0% {
opacity: 1;
}
17% {
opacity: 1;
}
25% {
opacity: 0;
}
92% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#backgroundchange div:nth-of-type(1) {
animation-delay: 6s;
}
#backgroundchange div:nth-of-type(2) {
animation-delay: 4s;
}
#backgroundchange div:nth-of-type(3) {
animation-delay: 2s;
}
#backgroundchange div:nth-of-type(4) {
animation-delay: 0;
}
Thank you in advance.
I believe this is what you want. I'm not sure what browser you're using but if it's a webkit browser like chrome be sure to use the
-webkit-
prefix on your css animations:HTML
CSS
FIDDLE