问题
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