如何更改bootstrap轮播指示器和控件

时间:2014-03-29 12:00:51

标签: html css twitter-bootstrap twitter-bootstrap-3

我试图能够改变bootstrap轮播指示器和控件的位置。在这个网站上看起来像这个旋转木马。 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>

3 个答案:

答案 0 :(得分:8)

我无法打开您的示例网站,但您可以将这些指标移出当前位置并将其放置在您希望的位置。我将它们从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/

答案 1 :(得分:1)

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

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 -->

答案 2 :(得分:0)

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

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