jQuery OwlCarousel v1.3.3 - center align items

佐手、 提交于 2021-01-29 12:21:24

问题


I have 4 items in a row in carousel sample. There is still about 50% empty unused space. I want to align this items to the center.

I tried to center them via margin: 0 auto; and display: flex; align-items: center; but with no success.

I found that style="width: 2888px; left: 0px;" is computed bis javascript owl.carousel.custom.js. Changing left to some value will work but is not what I expected.

Here are the computed values of the class owl-wrapper-outer:

How should I fix this in order to align items to the center?


回答1:


Found one solution, by directly changing javascript:

base.$owlWrapper.css({
    "left": (carouselWidth / 2) - ((base.itemWidth * base.$owlItems.length) / 2)
});


来源:https://stackoverflow.com/questions/50372399/jquery-owlcarousel-v1-3-3-center-align-items

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!