您好我想在bootstrap3上做旋转木马滑块.
我尝试将旋转木马放入另一个旋转木马,但这不能正常工作.
我怎么能这样做?
我的源代码:
<!DOCTYPE HTML> <html> <head> <title>Bootstrap Carousel</title> <link href="css/carousel.css" rel="stylesheet" type="text/css" /> <script src="js/jquery-1.7.1.min.js" type="text/javascript"></script> <script src="js/bootstrap.min.js" type="text/javascript"></script> <script src="js/transition.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $('#oceanCarousel,#musiciansCarouse,#kinCarousel').carousel({ interval: false }); }); </script> </head> <body> <div id="wrapper"> <h1>Carousel gallery with One Image</h1> <!-- OCEAN galLERY --> <div id="musiciansCarousel" class="carousel slide"> <!-- Carousel items --> <div class="carousel-inner"> <div class="active item"> <a href="#"><img src="../images/large/musicians01.jpg"></a> </div> <div class="item"> <a href="#"><img src="../images/large/musicians02.jpg"></a> </div> <div class="item"> <a href="#"><img src="../images/large/musicians03.jpg"></a> </div> <div class="item"> <a href="#"><img src="../images/large/musicians04.jpg"></a> </div> <div class="item"> <!-- INSIDE --> <div id="kinCarousel" class="carousel slide"> <!-- Carousel items --> <div class="carousel-inner"> <div class="active item"> dldnlkdnndlkd <a href="#"><img src="../images/large/musicians01.jpg"></a> </div> <div class="item"> dndlkdnd <a href="#"><img src="../images/large/musicians02.jpg"></a> </div> <div class="item"> <a href="#"><img src="../images/large/musicians03.jpg"></a> </div> <div class="item"> <a href="#"><img src="../images/large/musicians04.jpg"></a> </div> <div class="item"> <a href="#"><img src="../images/large/musicians05.jpg"></a> </div> <a class="carousel-control left" href="#kinCarousel" data-slide="prev">‹</a> <a class="carousel-control right" href="#kinCarousel" data-slide="next">›</a> </div> <!-- INSIDE --> </div> </div> <!-- Carousel nav --> <a class="carousel-control left" href="#musiciansCarousel" data-slide="prev">‹</a> <a class="carousel-control right" href="#musiciansCarousel" data-slide="next">›</a> </div> <br /><br /><br /> </div> </body> </html>
解决方法
这是jsfiddle:
http://jsfiddle.net/vittore/Q2TYv/1907/
>为第一个项目渲染带有幻灯片的旋转木马
>为隐藏div中的所有项目渲染所有幻灯片,并为每个幻灯片添加类或数据项目等.
>使用顶部按钮有条件地添加和删除所有幻灯片,但对于特定项目
>更新幻灯片后重置轮播数据
>将它留在旋转木马上左右移动滑块.
以下是项目按钮的示例代码:
$('.carousel-linked-projects > li > a').click(function() { $('.carousel-linked-projects').find('a').removeClass('active') $(this).addClass('active') var currentProject = $(this).data('project') $('#myCarousel').find('.item').remove() $slides = $('#allSlides').find('.item').filter( function ( i ) { return $(this).data('project') == currentProject }) $slides.eq(0).addClass('active') $('#myCarousel').find('.carousel-inner').append($slides) $('#myCarousel').carousel("pause").removeData().carousel(1) return false });
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。