Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Owl Carousel - width is calculated wrong

I have three responsive items (imgs), but every time the Owl-Carousel is loaded, the owl-wrapper width is two times the size of all images together. For example; if the images fullsize takes 1583 px, the owl-wrapper takes 1583 * 3 * 2 = 9498px, and all site takes this width, instead the full size (1583 px).

The issue: http://nacionalempreendimen.web2144.uni5.net

HTML

<div id="promoted-carousel">
    <div class="item"><img src="assets/img/tmp/1.jpg"></div>
    <div class="item"><img src="assets/img/tmp/2.jpg"></div>
    <div class="item"><img src="assets/img/tmp/3.jpg"></div>
</div>

CSS

#promoted-carousel .item img{
    display: block;
    width: 100%;
    height: auto;
}

JS

$('#promoted-carousel').owlCarousel({
    autoPlay: 5000,
    stopOnHover: true,
    singleItem: true
});

UPDATE

I saw that when I put #promoted-carousel div out of .page-wrapper div, it works properly. But my knowledge of css it is not sufficient to understand why it works.

like image 501
Vinicius Ottoni Avatar asked Mar 31 '15 18:03

Vinicius Ottoni


People also ask

How do you make an owl carousel responsive?

Setting of the responsive is very simple. Structure of responsive option: responsive : { // breakpoint from 0 up 0 : { option1 : value, option2 : value, ... }, // breakpoint from 480 up 480 : { option1 : value, option2 : value, ... }, // breakpoint from 768 up 768 : { option1 : value, option2 : value, ... } }

How do I change the height on my owl carousel?

Setup. Add height to div="owl-wrapper-outer" so you can use diffrent heights on each slide. Use it only for one item per page setting.

Does owl carousel use jQuery?

OWL Carousel is an enabled jQuery plugin that lets you create responsive carousel sliders. Create a list of 2,232,000 OWL Carousel websites with company and contact details.


2 Answers

it helped me:

setTimeout(function() {
    $('#promoted-carousel').owlCarousel({
        autoPlay: 5000,
        stopOnHover: true,
        singleItem: true
    });
}, 10);
like image 73
maLikiz Avatar answered Sep 19 '22 15:09

maLikiz


this solution helped me too , if your theme is using bootstrape 4 and the owl plugin is using bootstrape 3 this will fix the owl width issue

 setTimeout(function() {
$('#promoted-carousel').owlCarousel({
    autoPlay: 5000,
    stopOnHover: true,
    singleItem: true
});
}, 10);
like image 27
Disney Land 2017 Avatar answered Sep 20 '22 15:09

Disney Land 2017