How to use owl carousel vertically?

亡梦爱人 提交于 2019-12-04 19:09:24

问题


I did not want to take the plugin code so I was wondering if someone had already managed to use plugin vertically. It's a shame on the part of this plugin can be used horizontally. Sorry for langage...


回答1:


Here is a CodePen that solves this:

http://codepen.io/dapinitial/pen/xZaRqz

$(".owl-carousel").owlCarousel({
  loop: true,
  autoplay: true,
  items: 1,
  nav: true,
  autoplayHoverPause: true,
  animateOut: 'slideOutUp',
  animateIn: 'slideInUp'
});



回答2:


Regard to the 2.0 beta it's currently not possible to slide vertically. However, the complexity has been significantly reduced by the refactoring and the plugin architecture to make room for more features. This includes in particular an API with which the various animation effects can be broken down into separate animation providers. Thus, a vertical slide would certainly be possible. However, the feature is ambitious and there are some problems to solve. Here is the current roadmap.




回答3:


You could rotate the carousel and then rotate the items back, like this:

<div class="owl-carousel owl-theme">
  <img class="item" src="http://placehold.it/320x240?text=Slide%200">
  <img class="item" src="http://placehold.it/320x240?text=Slide%201">
  <img class="item" src="http://placehold.it/320x240?text=Slide%202">
  <img class="item" src="http://placehold.it/320x240?text=Slide%203">
  <img class="item" src="http://placehold.it/320x240?text=Slide%204">
  <img class="item" src="http://placehold.it/320x240?text=Slide%205">
  <img class="item" src="http://placehold.it/320x240?text=Slide%206">
  <img class="item" src="http://placehold.it/320x240?text=Slide%207">
</div>

//CSS ______________

.owl-carousel{
   transform: rotate(90deg);
   width: 270px; 
   margin-top:100px;
 } 
.item{
   transform: rotate(-90deg);
 }
.owl-carousel .owl-nav{
   display: flex;
   justify-content: space-between;
   position: absolute;
   width: 100%;
   top: calc(50% - 33px);
 }
div.owl-carousel .owl-nav .owl-prev, div.owl-carousel .owl-nav .owl-next{
    font-size:36px;
    top:unset;
    bottom: 15px; 
}



/* JS ____________*/
$( document ).ready(function() {
    $(".owl-carousel").owlCarousel({
         items: 3,
         loop: false,
         mouseDrag: false,
         touchDrag: false,
         pullDrag: false,
         rewind: true,
         autoplay: true,
         margin: 0,
         nav: true
     });
});

Check this a codepen : https://codepen.io/marcogu00/pen/eLeWMq

Notice that drag must be disabled as it wont work properly



来源:https://stackoverflow.com/questions/25079495/how-to-use-owl-carousel-vertically

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