Bootstrap一个旋转木马有两个旋转木马指示器 [英] Bootstrap one carousel with two carousel-indicators

查看:144
本文介绍了Bootstrap一个旋转木马有两个旋转木马指示器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我要做的是,我有一个带有8个幻灯片的Bootstrap轮播。我正在使用2个轮播指示器。

Basically what I am trying to do is, I have one Bootstrap carousel with 8 slides in it.I am using 2 carousel-indicators.

这是我的第一个指标,它可以正常工作 .active class

This is my first indicator it work fine with .active class

<ol class="rightci carousel-indicators">
  <li data-target="#carousel-example-generic" data-slide-to="0" ></li>
</ol>

这是我的第二个指标它工作正常。当我点击链接轮播幻灯片改变完美但 .active 课程剂量不会自动改变而不是第一个指标 .active 改变罚款。

this is my Second Indicator it works fine.when I click on the link carousel slides change perfectly but .active class dose not change automatically rather on first indicators .active changes fine.

<div class="left leftci carousel-indicators">
<a href=""><span class="leftindicators active" data-target="#carousel-example-generic" data-slide-to="0">slide1</span></a>
</div>

帮助我

推荐答案

我认为你需要编写一些自定义js默认情况下Bootstrap没有这个功能,所以你需要制作自己的 carousel-indicators

I think you need to write some custom js Bootstrap has not this functionality by default so you need to make your own carousel-indicators

css

.carousel-indicators2 {
  position: absolute;
  top: 10px;
  left: 50%;
  z-index: 15;
  width: 60%;
  padding-left: 0;
  margin-left: -30%;
  text-align: center;
  list-style: none;
}

.carousel-indicators2 li {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin: 1px;
  text-indent: -999px;
  cursor: pointer;
  background-color: #000\9;
  background-color: rgba(0, 0, 0, 0);
  border: 1px solid #fff;
  border-radius: 10px;
}
.carousel-indicators2 .active {
    width: 12px;
    height: 12px;
    margin: 0;
    background-color: #fff;
}

JS

$('.carousel').on('slid.bs.carousel', function() {
  $(".carousel-indicators2 li").removeClass("active");
  indicators = $(".carousel-indicators li.active").data("slide-to");
  a = $(".carousel-indicators2").find("[data-slide-to='" + indicators + "']").addClass("active");
  console.log(indicators);

})

小提琴

Fiddle

这篇关于Bootstrap一个旋转木马有两个旋转木马指示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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