Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.