gpt4 book ai didi

javascript - Twitter-Bootstrap-3 轮播修改

转载 作者:太空宇宙 更新时间:2023-11-04 03:48:12 24 4
gpt4 key购买 nike

伙计们,我有一个完美运行的轮播。现在我希望能够稍微修改它,所以这是我的脚本:

<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
<div class="item active" id="1">
<center>Images go here!</center>
</div>
<div class="item" id="2">
<center>Imsdfsdfsfsdfsdfsdfsfsdfsdf</center>
</div>
<div class="item" id="3">
<center>Imasdfsdfsdfsdfre!</center>
</div>
</div>

<a class="carousel-control left" href="javascript:;" data-target="#myCarousel" data-slide="prev">
<span class="icon-prev"></span>
</a>
<a class="carousel-control right" href="javascript:;" data-target="#myCarousel" data-slide="next">
<span class="icon-next"></span>
</a>

<br /><br />
<div class="container">
<ul style="float:left; margin-top: 200px; display:inline-block;">
<li style="display:inline-block;"><a href="javascript:;" data-target="#myCarousel" data-slide="prev">Dashobard</a></li>
<li style="display:inline-block;"><a href="javascript:;" data-target="#myCarousel" data-slide="prev next">Timeline</a></li>
<li style="display:inline-block;"><a href="javascript:;" data-target="#myCarousel" data-slide="prev">Visionboard</a></li>
</ul>
</div>
</div>

如您所料工作 - 现在我想在下面有 3 个链接,比如 link1、link2、link3,当您单击它时,它会更改轮播中的幻灯片,除此之外,我希望在下面添加标题 http://jsfiddle.net/iamdanbarrett/CbtT9/每个链接。请参阅我的示例图片 - 我已尝试使用当前控件并尝试修改它们但没有成功。

这是一个 fiddle :Fiddle

An example of how I need the slider to behave. So the links control the image and also the captions below.

最佳答案

如果你想实现类似 this 的目标这是你必须做的:

HTML代码:

<div id="myCarousel" class="carousel slide">
<div class="carousel-inner">
<div class="active item" id="id1">
<img src="http://placehold.it/300x200/888&text=Item 1" />
</div>
<div class="item" id="id2">
<img src="http://placehold.it/300x200/aaa&text=Item 2" />
</div>
<div class="item" id="id3">
<img src="http://placehold.it/300x200/444&text=Item 3" />
</div>
</div>

<a class="carousel-control left" href="#myCarousel" data-slide="prev">&lsaquo;</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">&rsaquo;</a>
</div>

<div class="container">
<ul>
<li style="display:inline-block;"><a href="javascript:slideTo('0')">Dashobard</a></li>
<li style="display:inline-block;"><a href="javascript: slideTo('1')">Timeline</a></li>
<li style="display:inline-block;"><a href="javascript: slideTo('2')">Visionboard</a></li>
</ul>
</div>

JavaScript 代码:

function slideTo(valoare){
if (valoare == 0) $('#myCarousel').carousel(0)
if (valoare == 1) $('#myCarousel').carousel(1)
if (valoare == 2) $('#myCarousel').carousel(2)
}

我在这个例子中使用的 CSS 代码:

#myCarousel {
margin-top: 40px;
}

.carousel-linked-nav,
.item img {
display: block;
margin: 0 auto;
}

.carousel-linked-nav {
width: 120px;
margin-bottom: 20px;
}

.container {
text-align: center;
}

ul {margin: 0;}

这是 jsfiddle

这个例子使用.carousel(number)

将轮播循环到特定帧(基于 0,类似于数组)。

更新 1:

更新 2:

关于javascript - Twitter-Bootstrap-3 轮播修改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23787751/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com