Skip to content

Instantly share code, notes, and snippets.

@marushu
Last active January 22, 2016 02:52
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 marushu/8f6229f1f133a61c3cab to your computer and use it in GitHub Desktop.
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.
/**
* 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