我不想使用插件代码,所以我想知道是否有人已经设法垂直使用插件。遗憾的是,这个插件可以横向使用。对不起语言...
问问题
104789 次
5 回答
6
您可以旋转旋转木马,然后将项目旋转回来,如下所示:
$(document).ready(function() {
$(".owl-carousel").owlCarousel({
items: 3,
loop: false,
mouseDrag: false,
touchDrag: false,
pullDrag: false,
rewind: true,
autoplay: true,
margin: 0,
nav: true
});
});
@import "https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.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;
}
<div class="owl-carousel owl-theme">
<img class="item" src="https://via.placeholder.com/320x240?text=Slide%200">
<img class="item" src="https://via.placeholder.com/320x240?text=Slide%201">
<img class="item" src="https://via.placeholder.com/320x240?text=Slide%202">
<img class="item" src="https://via.placeholder.com/320x240?text=Slide%203">
<img class="item" src="https://via.placeholder.com/320x240?text=Slide%204">
<img class="item" src="https://via.placeholder.com/320x240?text=Slide%205">
<img class="item" src="https://via.placeholder.com/320x240?text=Slide%206">
<img class="item" src="https://via.placeholder.com/320x240?text=Slide%207">
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>
检查这个代码笔:https ://codepen.io/marcogu00/pen/eLeWMq
请注意,必须禁用拖动,因为它不能正常工作
于 2018-09-07T16:03:45.907 回答
5
这是解决此问题的 CodePen:
http://codepen.io/dapinitial/pen/xZaRqz
$(".owl-carousel").owlCarousel({
loop: true,
autoplay: true,
items: 1,
nav: true,
autoplayHoverPause: true,
animateOut: 'slideOutUp',
animateIn: 'slideInUp'
});
于 2016-02-03T19:36:10.263 回答
0
仅适用于方形图像或方形元素遵循启用鼠标的示例https://codepen.io/luis7lobo9b/pen/zYrEqKj
<!-- HTML -->
<div class="wrapper">
<div class="owl-carousel owl-carousel-vertical">
<div class="item">
<img src="<!--https://via.placeholder.com/300.png/000/fff-->">
</div>
<div class="item">
<img src="<!--https://via.placeholder.com/300.png/333/fff-->">
</div>
<div class="item">
<img src="<!--https://via.placeholder.com/300.png/666/fff-->">
</div>
</div>
</div>
/* CSS */
.wrapper{
height: 300px;
width: 300px;
}
.owl-carousel-vertical{
transform: rotate3d(0, 0, 1, 90deg);
}
.owl-carousel-vertical .item{
transform: rotate3d(0, 0, 1, -90deg);
}
// JS
$(function(){
$('.owl-carousel').owlCarousel({
items: 1,
loop: false,
nav: false,
margin: 0
});
// this code below enables drag and drop vertically. Unfortunately I was unable to disable horizontal drag and drop so it will remain active, but we already have something now =D
$('.owl-carousel').data('owl.carousel').difference = function(first, second) {
return {
x: first.x - second.x + (first.y - second.y),
y: first.y - second.y
};
};
});
于 2020-06-29T00:32:27.330 回答
0
.item {
transform: rotate(-90deg);
}
.owl-carousel{
transform: rotate(90deg);
}
于 2021-04-16T13:02:33.807 回答