Created
April 28, 2015 10:05
-
-
Save alexpchin/5d35d09844a7c0b62c70 to your computer and use it in GitHub Desktop.
Fade in background image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HTML | |
<div class="background-image"></div> | |
// CSS | |
@-webkit-keyframes fade-in { | |
0% { opacity: 0; } | |
100% { opacity: 1; } | |
} | |
.background-image { | |
background: url('http://graygilmore.com/images/bk-body.jpg') no-repeat center center fixed; | |
-webkit-background-size: cover; | |
-moz-background-size: cover; | |
-o-background-size: cover; | |
background-size: cover; | |
position: absolute; | |
top: 0; | |
right: 0; | |
bottom: 0; | |
left: 0; | |
opacity: 0; | |
-webkit-animation-name: fade-in; | |
-webkit-animation-duration: 1s; | |
-webkit-animation-timing-function: ease-in; | |
-webkit-animation-iteration-count: 1; | |
-webkit-animation-delay: 2s; | |
} | |
.background-image.visible { | |
opacity: 1; | |
} | |
// JS | |
$(document).ready(function() { | |
$('.background-image').on('webkitAnimationEnd', function(e) { | |
$(this).addClass('visible'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment