How to use background images with owl carousel

后端 未结 4 1457
感情败类
感情败类 2021-01-19 03:24

I\'d like to use owl carousel with background images rather than tags, like used in http://driveshift.com/car/c10148. However, every example include

4条回答
  •  难免孤独
    2021-01-19 04:12

    Example:

    HTML:

    
    

    CSS:

    .owl-carousel figure {width:100%; height:450px; background-size:cover; background-position:center center; background-repeat:no-repeat;}
    

    JS:

    $('.owl-carousel').owlCarousel({
        onTranslated: function(me){
            $(me.target).find(".owl-item.active [data-src]:not(.loaded)").each(function(i,v){
                $(v).addClass("loaded").css("background-image", "url("+$(v).attr("data-src")+")");
            });
        }
    });
    

    Don't need use lazyLoad functions. Use animations on css to personalize your effects.

提交回复
热议问题