%ul.slideshow
%li
%h3 The Seasons
<!-- By Keven Law from Los Angeles, USA (Long Hot Summer......) [CC-BY-SA-2.0 (http://creativecommons.org/licenses/by-sa/2.0)], via Wikimedia Commons, http://commons.wikimedia.org/wiki/File%3AFlickr_-_law_keven_-_Long_Hot_Summer.......jpg -->
%span Summer
%li
<!-- By http://www.ForestWander.com [CC-BY-SA-3.0-us (http://creativecommons.org/licenses/by-sa/3.0/us/deed.en)], via Wikimedia Commons, http://commons.wikimedia.org/wiki/File%3ARed-fall-tree-lake_-_West_Virginia_-_ForestWander.png -->
%span Fall
%li
<!-- By Valerii Tkachenko [CC-BY-2.0 (http://creativecommons.org/licenses/by/2.0)], via Wikimedia Commons, http://commons.wikimedia.org/wiki/File%3AWinter_wonderland_Austria_mountain_landscape_(8290712092).jpg -->
%span Winter
%li
<!-- By Arman7 (Own work) [CC-BY-SA-3.0 (http://creativecommons.org/licenses/by-sa/3.0) or GFDL (http://www.gnu.org/copyleft/fdl.html)], via Wikimedia Commons, http://commons.wikimedia.org/wiki/File%3ABoroujerd_spring.jpg -->
%span Spring
View Compiled
@import "bourbon";
html {
min-height: 100%;
}
body {
height: 100%;
}
// length of each slide in seconds
$animation-delay: 6s;
.slideshow {
list-style: none;
z-index: 1;
li {
span {
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
color: transparent;
background-size: cover;
background-position: 50% 50%;
background-repeat: none;
opacity: 0;
z-index: 0;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
// multiply slide duration by the total number of slides
@include animation(imageAnimation $animation-delay * 4 linear infinite 0s);
}
h3 {
position: absolute;
text-align: center;
z-index: 2;
bottom: 150px;
left: 0;
right: 0;
opacity: 0;
font-size: em(65px);
font-family: 'Josefin Sans', sans-serif;
text-transform: uppercase;
color: #fff;
// multiply slide duration by the total number of slides
@include animation(titleAnimation $animation-delay * 4 linear 1 0s);
@media only screen and (min-width: 768px) {
bottom: 30px;
font-size: em(130px);
}
@media only screen and (min-width: 1024px) {
font-size: em(175px);
}
}
}
}
// add and remove new slides here, maintaning the animation-delay format
.slideshow li:nth-child(1) span {
background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/203277/summer-slide.jpg);
}
.slideshow li:nth-child(2) span {
background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/203277/fall-slide.jpg);
@include animation-delay($animation-delay);
}
.slideshow li:nth-child(3) span {
background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/203277/winter-slide.jpg);
@include animation-delay($animation-delay * 2);
}
.slideshow li:nth-child(4) span {
background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/203277/spring-slide.jpg);
@include animation-delay($animation-delay * 3);
}
// animation for the slideshow images
@include keyframes(imageAnimation) {
0% {
opacity: 0;
@include animation-timing-function(ease-in);
}
12.5% {
opacity: 1;
@include animation-timing-function(ease-out);
}
25% {
opacity: 1;
}
37.5% {
opacity: 0;
}
100% {
opacity: 0;
}
}
// animation for the title
@include keyframes(titleAnimation) {
0% {
opacity: 0;
}
12.5% {
opacity: 1;
}
25% {
opacity: 1;
}
37.5% {
opacity: 0;
}
100% {
opacity: 0;
}
}
// modernizr is used to show the first slide as a fallback for when css animations are not supported
.no-cssanimations .slideshow li span {
opacity: 1;
}
View Compiled
This Pen doesn't use any external JavaScript resources.