猫头鹰轮播2 Nav侧面 [英] Owl Carousel 2 Nav on Sides

查看:37
本文介绍了猫头鹰轮播2 Nav侧面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Owl Carousel版本2,找不到用于将导航设置在轮播的侧面(如左右人字形或箭头)的示例.你如何做到的?

Hi I'm using Owl Carousel version 2 and can't find an example to put the navigation on the sides of the carousel like right and left chevrons or arrows. How do you do it?

推荐答案

我昨天才这样做:)

首先确保在配置中打开了导航

Firstly make sure nav is turned on in the config

https://owlcarousel2.github.io/OwlCarousel2/docs/api-options.html

   $('#_samewidth_images').owlCarousel({
      margin:10,
      autoWidth:false,
      nav:true,
      items:4,
      navText : ['<i class="fa fa-angle-left" aria-hidden="true"></i>','<i class="fa fa-angle-right" aria-hidden="true"></i>']
  })

这会将控件注入DOM中,请参阅

This will inject the controls into the DOM, see

https://owlcarousel2.github.io/OwlCarousel2/docs/api-classes.html

<div class="owl-carousel owl-theme owl-loaded">
    <div class="owl-stage-outer">
        <div class="owl-stage">
            <div class="owl-item">...</div>
            <div class="owl-item">...</div>
            <div class="owl-item">...</div>
        </div>
    </div>
    <div class="owl-controls">
        <div class="owl-nav">
            <div class="owl-prev">prev</div>
            <div class="owl-next">next</div>
        </div>
        <div class="owl-dots">
            <div class="owl-dot active"><span></span></div>
            <div class="owl-dot"><span></span></div>
            <div class="owl-dot"><span></span></div>
        </div>
    </div>
</div>

接下来使用CSS来放置Next和Prev控件,这是我使用的:

Next use CSS to position the Next and Prev controls, this is what I used:

.owl-prev {
    width: 15px;
    height: 100px;
    position: absolute;
    top: 40%;
    margin-left: -20px;
    display: block !important;
    border:0px solid black;
}

.owl-next {
    width: 15px;
    height: 100px;
    position: absolute;
    top: 40%;
    right: -25px;
    display: block !important;
    border:0px solid black;
}
.owl-prev i, .owl-next i {transform : scale(1,6); color: #ccc;}

对于我的图标,我使用了Font Awesome,但您可以使用任何类似的东西.请注意javascript代码中的 navText ,这是您放置自定义HTML的地方.我猜您也可以使用图片(或将其放在.owl-next和.owl-prev div的背景中.请注意,我使用了transform使箭头变高了.

For my icons I used Font Awesome but you could use anything similar. Note the navText in the javascript code, this is where you put your custom HTML. I guess you could use an image too (or put it in the background of the .owl-next and .owl-prev divs. Note I used transform to make my arrows higher.

这篇关于猫头鹰轮播2 Nav侧面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆