猫头鹰轮播无法使用引导标签导航

时间:2018-05-24 08:46:13

标签: javascript jquery twitter-bootstrap tabs owl-carousel-2

我是jquery的新手。 我想使用owl carousel来滑动我的导航项。但它不起作用。

这是我的代码:

HTML

<div class="container">
  <div class="nav nav nav-pills bottom owl-carousel"  id="owler"  role="tablist">
    <div role="tab" class="tab-red   active  item expert-item">
       <a href="#red-tab" aria-controls="home" role="tab" data-toggle="tab">
    red
       </a>
    </div>
    <div role="tab" class="tab-orange   item expert-item">
       <a href="#orange-tab" aria-controls="home" role="tab" data-toggle="tab">
          orange
       </a>
    </div>
  </div>
</div>

JS

 $("#owler").owlCarousel({
   responsiveClass:true,
   center: true,
   loop:true,
   autoplay:false,
   nav: false,
   navText: [
    '<i class="fa fa-chevron-circle-left" aria-hidden="true"></i>',
    '<i class="fa fa-chevron-circle-right" aria-hidden="true"></i>'
   ]
});

Live links

提前致谢。

2 个答案:

答案 0 :(得分:1)

实际上它可行,但您只需要在导航链接中添加更多选项卡。 请查看this example以供参考。

<强> HTML:

<div class="nav nav-tabs user-tabs bottom owl-carousel"  id="owler"  role="tablist">
    <div role="presentation" class="tab-red   active  item expert-item">
        <a href="#red-tab" aria-controls="home" role="tab" data-toggle="tab">
        name
    </a>
    </div>
  <div role="presentation" class="tab-red   active  item expert-item">
        <a href="#red-tab" aria-controls="home" role="tab" data-toggle="tab">
        name
    </a>
    </div>
  <div role="presentation" class="tab-red   active  item expert-item">
        <a href="#red-tab" aria-controls="home" role="tab" data-toggle="tab">
        name
    </a>
    </div>
  <div role="presentation" class="tab-red   active  item expert-item">
        <a href="#red-tab" aria-controls="home" role="tab" data-toggle="tab">
        name
    </a>
    </div>
  <div role="presentation" class="tab-red   active  item expert-item">
        <a href="#red-tab" aria-controls="home" role="tab" data-toggle="tab">
        name
    </a>
    </div>
  <div role="presentation" class="tab-orange   item expert-item">
        <a href="#orange-tab" aria-controls="home" role="tab" data-toggle="tab">
              roll
        </a>
    </div>
   <div role="presentation" class="tab-green    item expert-item">
        <a href="#green-tab" aria-controls="home" role="tab" data-toggle="tab">
             subject
        </a>
    </div>
    <div role="presentation" class="tab-yellow    item expert-item">
        <a href="#yellow-tab" aria-controls="home" role="tab" data-toggle="tab">
            and what
        </a>
    </div>
</div>

如果您没有其他导航项,您可能还需要缩小所需的标签以填充剩余空间(例如,在Flexbox容器内的元素上使用flex属性)。

答案 1 :(得分:1)

添加更多导航项,它将起作用。