admin管理员组文章数量:1334819
Is it possible to prevent the caption of a bootstrap carousel from sliding with the background image, and instead, on 'slide' fade out, and on 'slid' the new caption fade in?
Is it possible to prevent the caption of a bootstrap carousel from sliding with the background image, and instead, on 'slide' fade out, and on 'slid' the new caption fade in?
Share Improve this question asked Jul 26, 2013 at 12:38 user1949366user1949366 4652 gold badges6 silver badges17 bronze badges4 Answers
Reset to default 3I prefer using the CSS-only solution:
.item.next .carousel-caption {
opacity: 0;
}
.carousel-caption {
transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-webkit-transition: opacity .25s ease-in-out;
}
It does rely on CSS3 transitions and does therefore not work in older browsers (for IE that means atleast version 10) but it's time to code for the future!
Use jQuery to attach functions to the 'slid' and 'slide' events...
$('#myCarousel').on('slide',function(){
$('.carousel-caption').fadeOut(300);
})
$('#myCarousel').on('slid',function(){
$('.carousel-caption').fadeIn(600);
})
Demo with animation: http://bootply./69740
For Bootstrap 3 it would be
$('#myCarousel').on('slide.bs.carousel',function(){
$('.carousel-caption').fadeOut(300);
})
$('#myCarousel').on('slid.bs.carousel',function(){
$('.carousel-caption').fadeIn(600);
})
This works... It still sort of slides with the carousel, but you do get the fadeOut and fadeIn affect.
$('#myCarousel').on('slide',function(){
$('#myCarousel .active .carousel-caption').fadeOut();
});
$('#myCarousel').on('slid',function(){
$('#myCarousel .active .carousel-caption').fadeIn();
});
Here is a fiddle demo.
本文标签: javascriptBootstrap Carousel Text FadeStack Overflow
版权声明:本文标题:javascript - Bootstrap Carousel Text Fade - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742380955a2464079.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论