繁体   English   中英

如何更改引导程序轮播指示器和控件

[英]How to change the bootstrap carousel indicators and controls

我坚持试图能够更改引导轮播指示器和控件的位置。 在这个网站上看起来像这个旋转木马。 http://www.mitre10.co.nz/指示器和控件是否位于底部并远离图像。

这是我的实时视图http://codepen.io/riwakawebsitedesigns/pen/qdiup

<header id="masterhead">
<div class="container">  
<div class="slideshow">
<div id="slideshow" class="carousel slide" data-ride="carousel">

          <ol class="carousel-indicators">   
            <li data-target="#slideshow" data-slide-to="0" class="active"></li>
            <li data-target="#slideshow" data-slide-to="1"></li>
            <li data-target="#slideshow" data-slide-to="2"></li>
    <li data-target="#slideshow" data-slide-to="3"></li>
        </ol>

        <div class="carousel-inner">

            <div class="item active">
          <img src="http://s20.postimg.org/wgz1zd3wd/slide1.jpg" alt="slide"/>
            </div>

            <div class="item">
          <img src="http://s20.postimg.org/l3cio5tdp/slide2.jpg" alt="slide"/>
            </div>

            <div class="item">
            <img src="http://s20.postimg.org/w0ducxg59/slide3.jpg" alt="slide"/>
            </div>

            <div class="item">
            <img src="http://s20.postimg.org/lrld73s3h/slide4.jpg" alt="slide"/>
            </div>

        </div>
        <a class="left carousel-control" href="#slideshow" data-slide="prev">
            <span class="glyphicon glyphicon-chevron-left"></span>
        </a>
        <a class="right carousel-control" href="#slideshow" data-slide="next">
            <span class="glyphicon glyphicon-chevron-right"></span>
        </a>
</div>

</div> 
</div>
</div>
</div>
</header>

我无法打开您的示例网站,但您可以将这些指标移出当前位置并将其放置在您希望的位置。 我将它们从CodePen的标题中移出,将它们包装在一个容器中,并添加了一些样式以将它们移动到图像下方并将它们居中:

<div class="carousel-controls">
    <a class="left carousel-control" href="#slideshow" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left"></span>
    </a>
    <ol class="carousel-indicators">   
        <li data-target="#slideshow" data-slide-to="0" class="active"></li>
        <li data-target="#slideshow" data-slide-to="1"></li>
        <li data-target="#slideshow" data-slide-to="2"></li>
        <li data-target="#slideshow" data-slide-to="3"></li>
    </ol>
    <a class="right carousel-control" href="#slideshow" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right"></span>
    </a>
</div>

CSS:

.carousel-controls{
 position:relative; 
  width:300px;
  margin:0 auto;
}

.carousel-indicators{
   top:0px; 
}

参考: http//codepen.io/anon/pen/tayfk/

这是一个旋转木马的模板,带有可定位的控件,底部有一个跟踪幻灯片的进度导航栏。

http://codepen.io/TheNickelDime/

<!-- HTML -->

    <div class="Slideshow_carousel-wrapper container-fluid">
        <span class="Slideshow-ctl-L" onclick="carousel_left()"></span>
        <div class="carousel slide" data-ride="carousel"  ... </div>    
        <span class="Slideshow-ctl-R" onclick="carousel_right()"></span>

    </div>

<!-- /HTML -->

<!-- CSS -->

.Slideshow_carousel-wrapper {

    display: -webkit-flex;
    display:         flex;


    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;

    text-align:center;

    width:100%; 
}



/* SLIDESHOW CONTROLS LEFT / RIGHT */
.Slideshow-ctl-L {

    -webkit-flex: none;
     flex: none;

    z-index:200;

    top:40%;
    margin-right:5px;

    height:60px;
    width:16px;

    opacity:0.7;

    background-size:15px 60px;
    background-repeat:no-repeat;
    background-image: url( ... );
}



.Slideshow-ctl-R {

    -webkit-flex: none;
     flex: none;


    top:40%;
    margin-left:5px;

    height:60px;
    width:15px;


    opacity:0.7;

    background-size:15px 60px;
    background-repeat:no-repeat;
    background-image: url( ... );
}

<!-- CSS -->

您可以编辑bootstrap.js以将多个类识别为指示符。

var Carousel = function (element, options) {
    this.$element    = $(element)
    this.$indicators = this.$element.find('.carousel-indicators, .your-class-here')

您可以使用此 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); <!-- You can remove this line "This line makes you see the active indicator in the console in the browser" -->

})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM