Skip to content

Instantly share code, notes, and snippets.

@tonkec
Created April 10, 2016 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonkec/47459ea1654ef100f7f720a706d192fa to your computer and use it in GitHub Desktop.
Save tonkec/47459ea1654ef100f7f720a706d192fa to your computer and use it in GitHub Desktop.
Fullscreen background slideshow
<div class="bg-wrapper">
<div class="bg-img active"></div>
<div class="bg-img"></div>
<div class="bg-img"></div>
<div class="bg-img"></div>
</div>
<a href="http://codepen.io/tonkec" class="ua" target="_blank">
<i class="fa fa-user"></i></a>
$(document).ready(function(){
var imgs = $(".bg-img");
i = -1;
(function f() {
i = (i + 1) % imgs.length;
$(imgs).not(imgs[i]).removeClass("slide-active")
$(imgs[i]).addClass("slide-active")
setTimeout(f, 7000);
})();
});
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
/* IMGS ARE NOT MINE */
html,
body {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
.bg-img {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
-webkit-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
opacity: 0;
-webkit-transition: all 4s ease-in-out;
-moz-transition: all 4s ease-in-out;
-ms-transition: all 4s ease-in-out;
-o-transition: all 4s ease-in-out;
transition: all 4s ease-in-out;
-webkit-transform: scale(1);
-moz-transform: scale(1);
-ms-transform: scale(1);
-o-transform: scale(1);
transform: scale(1)
}
.bg-img:first-child {
background-image: linear-gradient(rgba(0, 0, 0, .3), rgba(0, 0, 0, .2)), url(http://p2cdn4static.sharpschool.com/UserFiles/Servers/Server_3200643/Image/ButterflyonYellowFlower.jpg);
}
.bg-img:nth-child(2) {
background-image: linear-gradient(rgba(0, 0, 0, .3), rgba(0, 0, 0, .2)), url(http://media02.hongkiat.com/ww-flower-wallpapers/roundflower.jpg);
}
.bg-img:nth-child(3) {
background-image: linear-gradient(rgba(0, 0, 0, .3), rgba(0, 0, 0, .2)), url(http://newflowerwallpaper.com/download/blue-flowers-images-and-wallpapers/blue-flowers-images-and-wallpapers-1.jpg);
}
.bg-img:nth-child(4) {
background-image: linear-gradient(rgba(0, 0, 0, .3), rgba(0, 0, 0, .2)), url(https://newevolutiondesigns.com/images/freebies/flowers-wallpaper-24.jpg);
}
.slide-active {
opacity: 1;
-webkit-transition: all 4s ease-in-out;
-moz-transition: all 4s ease-in-out;
-ms-transition: all 4s ease-in-out;
-o-transition: all 4s ease-in-out;
transition: all 4s ease-in-out;
-webkit-transform: scale(1.2);
-moz-transform: scale(1.2);
-ms-transform: scale(1.2);
-o-transform: scale(1.2);
transform: scale(1.2);
}
.ua {
position: absolute;
right: 20px;
bottom: 20px;
color: #fff;
font-size: 2em;
}
.fa {
color: #fff;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-ms-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
.ua:hover .fa {
color:#1ba2e7;
-webkit-transform: scale(1.5);
-moz-transform: scale(1.5);
-ms-transform: scale(1.5);
-o-transform: scale(1.5);
transform: scale(1.5);
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-ms-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment