📌 Objective: Learn how to create interactive sliders and carousels using Bootstrap’s built-in Carousel component.
🔹 1. Introduction to Bootstrap Carousels & Sliders
A carousel (slider) is used to display multiple images, text, or content slides in a rotating fashion.
💡 Why Use Bootstrap Carousels?
✔️ Pre-built structure – No extra JavaScript needed.
✔️ Responsive and touch-friendly – Works on all devices.
✔️ Supports images, text, and even videos.
🔹 2. Basic Bootstrap Carousel
A basic carousel contains:
1️⃣ .carousel
– The container
2️⃣ .carousel-inner
– Holds slides
3️⃣ .carousel-item
– Individual slides
4️⃣ Controls & indicators for navigation
✅ Example: Simple Image Carousel
🔹 What happens?
- The carousel cycles through images automatically.
- Left & right navigation buttons allow manual control.
🔹 3. Adding Indicators & Captions
Indicators allow users to jump between slides, while captions provide slide descriptions.
✅ Example: Carousel with Indicators & Captions
🔹 What happens?
- Indicators allow users to navigate between slides.
- Each slide has a caption with a title and description.
🔹 4. Controlling Carousel Speed & Autoplay
You can customize speed and autoplay behavior using data-bs-interval
.
✅ Example: Slower Auto-Scrolling Carousel
🔹 What happens?
- Each slide remains visible for a longer time before transitioning.
🔹 5. Creating a Manual (Non-Auto) Carousel
✅ Example: Disabling Auto Sliding
🔹 What happens?
- The carousel only moves when users click next or previous buttons.
🔹 6. Controlling Carousel with JavaScript
✅ Example: JavaScript-Powered Carousel Control
🔹 What happens?
- Clicking “Start” resumes autoplay, and “Stop” pauses the slider.
📝 Lesson Recap Quiz
🎯 Test your knowledge of Bootstrap Carousels.
📌 Multiple-Choice Questions (MCQs)
1️⃣ Which class is used to create a Bootstrap carousel?
a) .slider-bootstrap
b) .carousel
c) .bs-slider
d) .slideshow
✅ Correct Answer: b) .carousel
2️⃣ How do you disable auto-sliding in a Bootstrap carousel?
a) data-bs-autoplay="false"
b) data-bs-slide="none"
c) data-bs-ride="false"
d) data-bs-stop="true"
✅ Correct Answer: c) data-bs-ride="false"
🎯 Practical Challenge
✅ Create a Bootstrap carousel with three images and captions.
✅ Customize the interval speed of each slide.
✅ Add buttons to start and stop the carousel using JavaScript.
✅ Post your solution in the discussion forum for feedback!
Leave a Reply