示例(另见: http: //bootply.com/65289和http://bootply.com/65305)
更新 http://bootply.com/65305使用 data-title 和 data-content 属性来显示标题
jQuery插件
我将以下代码包装在插件中:http: //plugins.jquery.com/captionthumbcarousel/
html(包括您的图像列表):
<div class="container" id="firstrow">
<div class="row-fluid">
<div class="span3" id="thumbs">
<button id="previousimage">Previous</button>
<button id="nextimage">Next</button>
</div>
<div class="span6" id="currentimage"></div>
<div class="span3" id="titles"></div>
<div id="carousal">
<img src="http://placehold.it/350/0000FF" title="blue image 1">
<img src="http://placehold.it/350/CCEEFF" title="yelow image 2">
<img src="http://placehold.it/350/088A4B" title="green image 3">
<img src="http://placehold.it/350/C47451" title="orange image 4">
<img src="http://placehold.it/350/000000" title="black image 5">
<img src="http://placehold.it/350/8D38C9" title="voilet image 6">
</div>
</div>
</div>
javascript:
$('#carousal').hide();
var number = $('#carousal img').length;
var numberofthumbs = 4;
var current = 0;
var images = $.makeArray($('#carousal img').clone());
var ci = $.makeArray($('#carousal img').clone());
$('#nextimage').before(images[0]);
$('#nextimage').before(images[1]);
$('#nextimage').before(images[2]);
$('#nextimage').before(images[3]);
$('#titles').append('<span>' + images[number-1].title + '</span><br>');
$('#titles').append('<span>' + images[current].title + '</span><br>');
$('#titles').append('<span>' + images[current+1].title + '</span><br>');
$('#currentimage').html(ci[0]);
$('#previousimage').click(function()
{
$('#thumbs img').last().remove();
$('#previousimage').after(images[(current-1+number)%number]);
$('#titles span').last().remove();
$('#titles br').last().remove();
$('#titles').prepend('<span>' + images[(current-2+number)%number].title + '</span><br>');
current = ((current-1+number)%number);
$('#currentimage').html(ci[current]);
});
$('#nextimage').click(function()
{
$('#thumbs img').first().remove();
$('#nextimage').before(images[(current+numberofthumbs)%number]);
$('#titles span').first().remove();
$('#titles br').first().remove();
$('#titles').append('<span>' + images[(current+2)%number].title + '</span><br>');
current = ((current+1)%number);
$('#currentimage').html(ci[current]);
});
一些css来设置拇指的样式:
#thumbs img {width:25%; display: block;}
也许将您的图像放在一个列表中并使用 .html() 来获取图像的副本以更加灵活。