Last active
January 22, 2016 02:52
-
-
Save marushu/8f6229f1f133a61c3cab to your computer and use it in GitHub Desktop.
Each slider image set to background image.If you set style(background-size: cover), FlexSlider is now full screen.
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
/** | |
* Change image tag to this parent background image. | |
*/ | |
( function( $ ){ | |
$.when( | |
$.each( $( '.slides li' ), | |
function( index, elem ){ | |
var img = $( elem ).find( 'img' ); | |
var imgSrc = $( img ).attr( 'src' ); | |
console.log(encodeURIComponent(imgSrc)); | |
$( elem ).css({ | |
'backgroundImage': 'url(' + imgSrc + ')', | |
'backgroundRepeat': 'no-repeat', | |
'backgroundSize': 'cover', | |
'backgroundPosition': 'center center' | |
}); | |
})).then( function() { | |
$( '.slides li img' ).remove(); | |
}); | |
})( jQuery ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment