Home
Free Templates
Snippets
Categories
Blog
Contribute
Spicing Up the Bootstrap Carousel with CSS3 Animations
Home
Single Snippet
Sources and Credits:
Author: Codeceil
bootstrap 4.1.1
font-awesome4.7.0
Last update: April 15, 2021
Result
html
css
javascript
This is the caption for slide 1
This is the caption for slide 1
Button
This is the caption for slide 2
Button
This is the caption for slide 3
Button
Previous
Next
Demo by Antonietta Perna.
See article
.
.container { padding: 10px 15px; } .skyblue { background-color: #22c8ff; } .carousel-indicators { bottom: 0; } .carousel-control.right, .carousel-control.left { background-image: none; } .carousel-item { min-height: 350px; height: 100%; width:100%; } .carousel-caption h3, .carousel .icon-container, .carousel-caption button { background-color: #09c; } .carousel-caption h3 { padding: .5em; } .carousel .icon-container { display: inline-block; font-size: 25px; line-height: 25px; padding: 1em; text-align: center; border-radius: 50%; } .carousel-caption button { border-color: #00bfff; margin-top: 1em; } /* Animation delays */ .carousel-caption h3:first-child { animation-delay: 1s; } .carousel-caption h3:nth-child(2) { animation-delay: 2s; } .carousel-caption button { animation-delay: 3s; } h1 { text-align: center; margin-bottom: 30px; font-size: 30px; font-weight: bold; } .p { padding-top: 125px; text-align: center; } .p a { text-decoration: underline; } Resources
/* Demo Scripts for Bootstrap Carousel and Animate.css article * on SitePoint by Maria Antonietta Perna */ (function($) { //Function to animate slider captions function doAnimations(elems) { //Cache the animationend event in a variable var animEndEv = "webkitAnimationEnd animationend"; elems.each(function() { var $this = $(this), $animationType = $this.data("animation"); $this.addClass($animationType).one(animEndEv, function() { $this.removeClass($animationType); }); }); } //Variables on page load var $myCarousel = $("#carouselExampleIndicators"), $firstAnimatingElems = $myCarousel .find(".carousel-item:first") .find("[data-animation ^= 'animated']"); //Initialize carousel $myCarousel.carousel(); //Animate captions in first slide on page load doAnimations($firstAnimatingElems); //Other slides to be animated on carousel slide event $myCarousel.on("slide.bs.carousel", function(e) { var $animatingElems = $(e.relatedTarget).find( "[data-animation ^= 'animated']" ); doAnimations($animatingElems); }); })(jQuery);
Share snippt :
Related More Snippets
bootstrap 4.1.1
Bootstrap 4 Slider
Preview & Downlaod