0
我想在一個頁面上設置多個twitter引導程序傳送帶,但我不想使用不同的ID,因爲後面我會動態創建這些傳送帶。我的問題是,通過按下第一個輪播中的按鈕,我可以控制所有這些按鈕。我無法弄清楚如何正確解決元素。如何設置此代碼以便我可以分別控制每個輪播,使用類而不是ID?多個twitter Bootstrap傳送帶類控制
jsfidle: http://jsfiddle.net/RobRalph/shk63x3g/1/
HTML:
<body>
<!-- 1st carousel test -->
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="carousel slide" data-interval="false">
<div class="carousel-inner">
<div class="backview"></div>
<ol class="carousel-indicators" >
<li data-target = ".carousel" data-slide-to = "0" class="active"></li>
<li data-target = ".carousel" data-slide-to = "1"></li>
<li data-target = ".carousel" data-slide-to = "2"></li>
</ol>
<!-- carousel first page -->
<div class="item active">
<div class = "headeritem">
</div>
<div class = "bodyitem">
</div>
<div class = "carousel-caption">
<h3>1</h3>
<p>Lorum ipsum</p>
</div>
</div>
<!-- carousel second page -->
<div class="item">
<div class = "headeritem">
</div>
<div class = "bodyitem">
</div>
<div class = "carousel-caption">
<h3>2</h3>
<p>Lorum ipsum</p>
</div>
</div>
<!-- carousel third page -->
<div class="item">
<div class = "headeritem">
</div>
<div class = "bodyitem">
</div>
<div class = "carousel-caption">
<h3>3</h3>
<p>Lorum ipsum</p>
</div>
</div>
</div>
<a class = "carousel-control left" href = ".carousel" data-slide = "prev">
<span class = "icon-prev"></span>
</a>
<a class = "carousel-control right" href = ".carousel" data-slide = "next">
<span class = "icon-next"></span>
</a>
</div>
</div>
</div>
</div>
<!-- 2nd carousel test -->
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="carousel slide" data-interval="false">
<div class="carousel-inner">
<div class="backview"></div>
<ol class="carousel-indicators" >
<li data-target = ".carousel" data-slide-to = "0" class="active"></li>
<li data-target = ".carousel" data-slide-to = "1"></li>
<li data-target = ".carousel" data-slide-to = "2"></li>
</ol>
<!-- carousel first page -->
<div class="item active">
<div class = "headeritem">
</div>
<div class = "bodyitem">
</div>
<div class = "carousel-caption">
<h3>1</h3>
<p>Lorum ipsum</p>
</div>
</div>
<!-- carousel second page -->
<div class="item">
<div class = "headeritem">
</div>
<div class = "bodyitem">
</div>
<div class = "carousel-caption">
<h3>2</h3>
<p>Lorum ipsum</p>
</div>
</div>
<!-- carousel third page -->
<div class="item">
<div class = "headeritem">
</div>
<div class = "bodyitem">
</div>
<div class = "carousel-caption">
<h3>3</h3>
<p>Lorum ipsum</p>
</div>
</div>
</div>
<a class = "carousel-control left" href = ".carousel" data-slide = "prev">
<span class = "icon-prev"></span>
</a>
<a class = "carousel-control right" href = ".carousel" data-slide = "next">
<span class = "icon-next"></span>
</a>
</div>
</div>
</div>
</div>
額外的CSS:
.backview {
position:absolute;
top:0;
z-index:-99;
height:100%;
width:100%;
background: linear-gradient(rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.3)), url('https://scontent.xx.fbcdn.net/hphotos-xpa1/v/t1.0-9/p480x480/10408976_1175768429116191_8145612220139098697_n.jpg?oh=45022b3bbf32769af5bf339f40cb2cb1&oe=55F527C3') no-repeat center center;
background-size:cover;
}
.headeritem {
height:80px;
}
.bodyitem {
height:140px;
}
si除非我修改bootstrap.js,否則不可能使用Class? 我很害怕它會來的ID,我想我會看看如何動態添加特定的ID,不應該太糟糕了 – RobRalph