【发布时间】:2015-04-02 17:59:45
【问题描述】:
我想为 Twitters Bootstrap 轮播的标题设置动画。在标题中,我得到了一个 h1-Tag 和四个 h4-Tag。
我希望 h1 先淡入,然后再淡入 h4-Tags。在滑动到下一张图片之前,我想先淡出 h4-Tag,然后再淡出 h1-Tag。
我的 slider.js:
$('#carousel-example-generic').on('slide.bs.carousel', function () {
$("h1").fadeIn(2000);
});
$('#carousel-example-generic').on('slid.bs.carousel', function () {
$("h1").fadeOut(2000);
});
我的 HTML:
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="http://www.werkart-hannover.de/tl_files/images/projekte/neubau-einfamilienhaus-2.jpg" alt="...">
<div class="carousel-caption">
<h1>Here is a test title</h1>
<h4>Test</h4>
<h4>Test</h4>
<h4>Test</h4>
<h4>Test</h4>
</div>
</div>
<div class="item">
<img src="http://www.loth-haus.de/galerie/neubau_5232.jpg" alt="...">
<div class="carousel-caption">
<h1>Here is a test title</h1>
<h4>Test</h4>
<h4>Test</h4>
<h4>Test</h4>
<h4>Test</h4>
</div>
</div>
<div class="item">
<img src="http://www.loth-haus.de/galerie/neubau_5232.jpg" alt="...">
<div class="carousel-caption">
<h1>Here is a test title</h1>
<h4>Test</h4>
<h4>Test</h4>
<h4>Test</h4>
<h4>Test</h4>
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
另一个问题是我的动画只适用于第二张幻灯片。 如何像我描述的那样为标题内的元素设置动画? 这是我的小提琴:http://jsfiddle.net/7fh3o32y/
【问题讨论】:
标签: twitter-bootstrap carousel