Experience the powerful AI writing right inside WordPress
Show stunning before-and-after transformations with image sliders.
Improve user engagement by showing estimated reading time.
Written by Mahmuda Akter Isha
Showcase Designs Using Before After Slider.
Creating a responsive image slider is one of the easiest ways to make a website more visual, interactive, and engaging. Whether you want to display homepage banners, product images, portfolio projects, testimonials, travel photos, or featured services, an image slider helps you show multiple visuals in a clean and organized way.
The good news is that you do not need to write complex JavaScript from scratch. With HTML, CSS, and Bootstrap, you can create a professional image slider using Bootstrap’s built-in Carousel component.
In this tutorial, you will learn how to create a responsive image slider using HTML, CSS, and Bootstrap 5. We will cover the complete code, carousel controls, indicators, captions, autoplay, fade animation, responsive image settings, common problems, and useful customization tips.
By the end of this guide, you will be able to build a clean Bootstrap image slider that works smoothly on desktop, tablet, and mobile devices.
A Bootstrap image slider is a slideshow component that allows you to display multiple images one after another. In Bootstrap, this feature is commonly known as the Carousel component.
A carousel can include:
For example, you can use a Bootstrap image slider to display:
The best part is that Bootstrap already provides most of the slider functionality. You only need to add the correct HTML structure, Bootstrap CDN, images, and optional CSS customization.
Bootstrap is one of the most popular front-end frameworks for building responsive websites. It saves development time because it comes with ready-made components, layout utilities, and responsive design features.
Using Bootstrap for an image slider has several benefits:
You do not need advanced JavaScript knowledge to create a basic slider. Bootstrap handles the carousel functionality for you.
Bootstrap is designed for mobile-friendly websites. With the right classes, your image slider can automatically adjust to different screen sizes.
Instead of building slider logic manually, you can use Bootstrap’s existing carousel structure and customize it with CSS.
Bootstrap Carousel includes previous and next buttons, indicators, autoplay, and other useful options.
You can use Bootstrap image sliders for business websites, landing pages, portfolios, blogs, eCommerce sites, and personal websites.
Many older tutorials use Bootstrap 4 syntax. However, Bootstrap 5 has some important changes. If your Bootstrap carousel is not working, one common reason is mixing Bootstrap 4 attributes with Bootstrap 5 files.
Here is a quick comparison:
data-ride="carousel"
data-bs-ride="carousel"
data-target
data-bs-target
data-slide
data-bs-slide
sr-only
visually-hidden
For new websites, it is better to use Bootstrap 5 because it does not require jQuery and uses updated data attributes.
Example:
Bootstrap 4 uses:
Bootstrap 5 uses:
This small difference is very important. If you use Bootstrap 5 files but write Bootstrap 4 carousel code, your slider controls or autoplay may not work properly.
Before creating the image slider, you need a few basic things:
You can use local images from your project folder or online image URLs. For better performance, use optimized images with the same size or aspect ratio.
A simple folder structure can look like this:
project-folder/ │ ├── index.html └── images/ ├── slide-1.jpg ├── slide-2.jpg └── slide-3.jpg
Keeping your images inside an images folder makes the project easier to organize.
images
Now, let’s create a responsive image slider step by step.
First, create a file named index.html.
index.html
Inside the file, add the basic HTML structure:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Responsive Image Slider Using Bootstrap 5</title> </head> <body> </body> </html>
The viewport meta tag is important because it helps your slider display correctly on mobile devices.
viewport
Next, add Bootstrap 5 CSS inside the <head> section.
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
Your <head> section will look like this:
<head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Responsive Image Slider Using Bootstrap 5</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"> </head>
This loads Bootstrap’s CSS styles into your webpage.
Bootstrap Carousel needs a main wrapper with a unique ID.
Add this inside the <body> tag:
<body>
<div id="mainSlider" class="carousel slide" data-bs-ride="carousel"> </div>
Here:
id="mainSlider"
carousel
slide
The ID is very important because controls and indicators use this ID to target the correct slider.
Carousel indicators are the small dots or buttons that show how many slides are available and which slide is currently active.
Add this inside the carousel container:
<div class="carousel-indicators"> <button type="button" data-bs-target="#mainSlider" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button> <button type="button" data-bs-target="#mainSlider" data-bs-slide-to="1" aria-label="Slide 2"></button> <button type="button" data-bs-target="#mainSlider" data-bs-slide-to="2" aria-label="Slide 3"></button> </div>
Each button represents one slide.
The first button has the active class because the first slide should be visible when the page loads.
active
Now add the carousel slides.
<div class="carousel-inner"> <div class="carousel-item active"> <img src="images/slide-1.jpg" class="d-block w-100" alt="Responsive image slider first slide"> </div> <div class="carousel-item"> <img src="images/slide-2.jpg" class="d-block w-100" alt="Responsive image slider second slide"> </div> <div class="carousel-item"> <img src="images/slide-3.jpg" class="d-block w-100" alt="Responsive image slider third slide"> </div> </div>
Important notes:
carousel-item
d-block w-100
Now add navigation controls so users can move between slides manually.
<button class="carousel-control-prev" type="button" data-bs-target="#mainSlider" data-bs-slide="prev"> <span class="carousel-control-prev-icon" aria-hidden="true"></span> <span class="visually-hidden">Previous</span> </button> <button class="carousel-control-next" type="button" data-bs-target="#mainSlider" data-bs-slide="next"> <span class="carousel-control-next-icon" aria-hidden="true"></span> <span class="visually-hidden">Next</span> </button>
Make sure data-bs-target="#mainSlider" matches the carousel ID.
data-bs-target="#mainSlider"
If the ID does not match, the buttons will not work.
Bootstrap Carousel needs Bootstrap’s JavaScript bundle to work.
Add this before the closing </body> tag:
</body>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
The Bootstrap bundle includes the JavaScript required for carousel controls, transitions, autoplay, and other interactive components.
Bootstrap gives you the basic slider, but custom CSS helps you control image height, object fit, spacing, border radius, overlay, and overall design.
Add this CSS inside the <head> section using a <style> tag:
<style>
<style> .carousel-item img { height: 500px; object-fit: cover; } @media (max-width: 768px) { .carousel-item img { height: 300px; } } @media (max-width: 480px) { .carousel-item img { height: 220px; } } </style>
This CSS keeps all slider images the same height and prevents layout jumping between slides.
The object-fit: cover; property makes the images fill the slider area without stretching.
object-fit: cover;
Here is the complete code for creating a responsive image slider using HTML, CSS, and Bootstrap 5.
You can copy and paste this into your index.html file.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Responsive Image Slider Using HTML CSS and Bootstrap 5</title> <!-- Bootstrap 5 CSS --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"> <!-- Custom CSS --> <style> body { margin: 0; padding: 0; font-family: Arial, sans-serif; background: #f8f9fa; } .slider-section { max-width: 1100px; margin: 50px auto; padding: 0 15px; } .carousel { border-radius: 16px; overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); } .carousel-item img { height: 500px; object-fit: cover; } .carousel-caption { background: rgba(0, 0, 0, 0.45); padding: 20px; border-radius: 12px; } .carousel-caption h5 { font-size: 28px; font-weight: 700; } .carousel-caption p { font-size: 16px; margin-bottom: 0; } @media (max-width: 768px) { .carousel-item img { height: 320px; } .carousel-caption h5 { font-size: 20px; } .carousel-caption p { font-size: 14px; } } @media (max-width: 480px) { .carousel-item img { height: 240px; } .carousel-caption { padding: 12px; } .carousel-caption h5 { font-size: 18px; } .carousel-caption p { display: none; } } </style> </head> <body> <section class="slider-section"> <div id="mainSlider" class="carousel slide" data-bs-ride="carousel"> <!-- Carousel Indicators --> <div class="carousel-indicators"> <button type="button" data-bs-target="#mainSlider" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button> <button type="button" data-bs-target="#mainSlider" data-bs-slide-to="1" aria-label="Slide 2"></button> <button type="button" data-bs-target="#mainSlider" data-bs-slide-to="2" aria-label="Slide 3"></button> </div> <!-- Carousel Slides --> <div class="carousel-inner"> <div class="carousel-item active"> <img src="images/slide-1.jpg" class="d-block w-100" alt="Responsive Bootstrap image slider first slide"> <div class="carousel-caption"> <h5>Beautiful Website Slider</h5> <p>Create a responsive image slider using HTML, CSS, and Bootstrap 5.</p> </div> </div> <div class="carousel-item"> <img src="images/slide-2.jpg" class="d-block w-100" alt="Bootstrap carousel second slide with caption"> <div class="carousel-caption"> <h5>Fully Responsive Design</h5> <p>Your image slider will look great on desktop, tablet, and mobile devices.</p> </div> </div> <div class="carousel-item"> <img src="images/slide-3.jpg" class="d-block w-100" alt="Bootstrap image slider third slide example"> <div class="carousel-caption"> <h5>Easy to Customize</h5> <p>Add captions, autoplay, controls, indicators, and custom styles easily.</p> </div> </div> </div> <!-- Previous Button --> <button class="carousel-control-prev" type="button" data-bs-target="#mainSlider" data-bs-slide="prev"> <span class="carousel-control-prev-icon" aria-hidden="true"></span> <span class="visually-hidden">Previous</span> </button> <!-- Next Button --> <button class="carousel-control-next" type="button" data-bs-target="#mainSlider" data-bs-slide="next"> <span class="carousel-control-next-icon" aria-hidden="true"></span> <span class="visually-hidden">Next</span> </button> </div> </section> <!-- Bootstrap 5 JS Bundle --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script> </body> </html>
After adding this code, replace the image file paths with your own images:
images/slide-1.jpg images/slide-2.jpg images/slide-3.jpg
Then open the file in your browser. You should see a responsive Bootstrap image slider with captions, indicators, and navigation controls.
After creating the basic Bootstrap image slider, you can customize it based on your website design.
Here are some useful customization options.
To change the height of the slider, update the image height in CSS:
.carousel-item img { height: 600px; object-fit: cover; }
For a smaller slider, use:
.carousel-item img { height: 350px; object-fit: cover; }
Use different heights for different devices:
.carousel-item img { height: 500px; object-fit: cover; } @media (max-width: 768px) { .carousel-item img { height: 300px; } }
This helps your slider look better on both desktop and mobile screens.
To make the slider full width, remove the max-width wrapper or set it to 100%.
100%
.slider-section { width: 100%; margin: 0; padding: 0; } .carousel { border-radius: 0; }
This is useful for homepage hero sliders or landing page banners.
To make the slider look modern, add border radius and shadow:
.carousel { border-radius: 20px; overflow: hidden; box-shadow: 0 12px 35px rgba(0, 0, 0, 0.18); }
The overflow: hidden; property makes sure the images follow the rounded corners.
overflow: hidden;
Sometimes slider images look stretched or squeezed. To fix this, use:
.carousel-item img { width: 100%; height: 500px; object-fit: cover; }
The object-fit: cover; property keeps the image ratio natural while filling the slider area.
For product images where cropping is not ideal, use:
.carousel-item img { width: 100%; height: 500px; object-fit: contain; background: #f5f5f5; }
Use cover for banners and hero sections. Use contain for product images where the full image must stay visible.
cover
contain
Bootstrap provides default previous and next icons. You can make them easier to see by adding a dark background:
.carousel-control-prev-icon, .carousel-control-next-icon { background-color: rgba(0, 0, 0, 0.6); border-radius: 50%; padding: 20px; }
This helps when your slider images are light and the white icons are hard to see.
Captions help you add text, headings, descriptions, and call-to-action messages on top of slider images.
Here is a simple Bootstrap carousel slide with a caption:
<div class="carousel-item active"> <img src="images/slide-1.jpg" class="d-block w-100" alt="Bootstrap image slider with caption"> <div class="carousel-caption"> <h5>Modern Website Slider</h5> <p>Create attractive image sliders using HTML, CSS, and Bootstrap.</p> <a href="#" class="btn btn-primary">Learn More</a> </div> </div>
To style the caption, use CSS:
.carousel-caption { background: rgba(0, 0, 0, 0.5); padding: 24px; border-radius: 12px; } .carousel-caption h5 { font-size: 32px; font-weight: 700; } .carousel-caption p { font-size: 16px; }
Captions are useful for:
For mobile devices, keep captions short. Long text inside a small slider can make the design look crowded.
Bootstrap Carousel can automatically move from one slide to another.
To enable autoplay, add this attribute to the carousel container:
<div id="mainSlider" class="carousel slide" data-bs-ride="carousel">
To control the time between slides, use data-bs-interval.
data-bs-interval
<div class="carousel-item active" data-bs-interval="3000"> <img src="images/slide-1.jpg" class="d-block w-100" alt="Bootstrap carousel autoplay example"> </div>
Here, 3000 means 3000 milliseconds, or 3 seconds.
3000
You can set a different interval for each slide:
<div class="carousel-item active" data-bs-interval="2000"> <img src="images/slide-1.jpg" class="d-block w-100" alt="First slide"> </div> <div class="carousel-item" data-bs-interval="5000"> <img src="images/slide-2.jpg" class="d-block w-100" alt="Second slide"> </div>
This means the first slide stays for 2 seconds and the second slide stays for 5 seconds.
By default, Bootstrap Carousel uses a sliding animation. You can change it to a fade effect by adding the carousel-fade class.
carousel-fade
<div id="mainSlider" class="carousel slide carousel-fade" data-bs-ride="carousel">
Full example:
<div id="mainSlider" class="carousel slide carousel-fade" data-bs-ride="carousel"> <div class="carousel-inner"> <div class="carousel-item active"> <img src="images/slide-1.jpg" class="d-block w-100" alt="Bootstrap carousel fade effect first slide"> </div> <div class="carousel-item"> <img src="images/slide-2.jpg" class="d-block w-100" alt="Bootstrap carousel fade effect second slide"> </div> <div class="carousel-item"> <img src="images/slide-3.jpg" class="d-block w-100" alt="Bootstrap carousel fade effect third slide"> </div> </div> </div>
The fade effect is useful for:
It creates a smoother transition compared to the default sliding effect.
Bootstrap gives you responsive classes, but you still need to control image size properly.
Use this image class:
<img src="images/slide-1.jpg" class="d-block w-100" alt="Responsive Bootstrap carousel image">
d-block
w-100
Then use CSS:
For mobile screens:
@media (max-width: 768px) { .carousel-item img { height: 300px; } } @media (max-width: 480px) { .carousel-item img { height: 220px; } }
This makes the slider responsive and prevents images from becoming too tall on small screens.
Some older projects still use Bootstrap 4. If your website uses Bootstrap 4, the carousel syntax is slightly different.
Bootstrap 4 requires jQuery and Popper.js, while Bootstrap 5 does not.
Here is a simple Bootstrap 4 carousel example:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Bootstrap 4 Image Slider</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"> <style> .carousel-item img { height: 500px; object-fit: cover; } </style> </head> <body> <div id="oldSlider" class="carousel slide" data-ride="carousel"> <ol class="carousel-indicators"> <li data-target="#oldSlider" data-slide-to="0" class="active"></li> <li data-target="#oldSlider" data-slide-to="1"></li> <li data-target="#oldSlider" data-slide-to="2"></li> </ol> <div class="carousel-inner"> <div class="carousel-item active"> <img src="images/slide-1.jpg" class="d-block w-100" alt="Bootstrap 4 image slider first slide"> </div> <div class="carousel-item"> <img src="images/slide-2.jpg" class="d-block w-100" alt="Bootstrap 4 image slider second slide"> </div> <div class="carousel-item"> <img src="images/slide-3.jpg" class="d-block w-100" alt="Bootstrap 4 image slider third slide"> </div> </div> <a class="carousel-control-prev" href="#oldSlider" role="button" data-slide="prev"> <span class="carousel-control-prev-icon" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="carousel-control-next" href="#oldSlider" role="button" data-slide="next"> <span class="carousel-control-next-icon" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script> </body> </html>
Use this only when your project already depends on Bootstrap 4. For new projects, Bootstrap 5 is the better option.
Sometimes your Bootstrap image slider may not work as expected. Here are the most common problems and how to fix them.
This usually happens when the Bootstrap JavaScript file is missing.
Make sure this script is added before the closing </body> tag:
Also make sure you are using Bootstrap 5 attributes:
data-bs-ride="carousel" data-bs-target="#mainSlider" data-bs-slide="next"
Do not use Bootstrap 4 attributes with Bootstrap 5.
This often happens because the carousel ID and the control target do not match.
Example carousel ID:
<div id="mainSlider" class="carousel slide">
The control button must target the same ID:
<button class="carousel-control-next" type="button" data-bs-target="#mainSlider" data-bs-slide="next">
If your carousel ID is mainSlider, your target must be #mainSlider.
mainSlider
#mainSlider
Check the image file path.
For example:
<img src="images/slide-1.jpg" alt="Slider image">
This means your image should be inside an images folder.
Your folder should look like this:
project-folder/ ├── index.html └── images/ └── slide-1.jpg
Also check for spelling mistakes in the file name. Image paths are case-sensitive on many servers.
slide-1.jpg
and
Slide-1.jpg
may be treated as different files.
Images usually look stretched when width and height are forced without maintaining the image ratio.
Use:
For product images, use:
.carousel-item img { width: 100%; height: 500px; object-fit: contain; }
This happens when your images have different dimensions.
Use the same image size for all slides or apply a fixed height with CSS:
.carousel-item img { height: 500px; object-fit: cover; }
This keeps the slider height consistent.
If you use more than one image slider on the same page, each carousel must have a unique ID.
Wrong example:
<div id="mainSlider" class="carousel slide"></div> <div id="mainSlider" class="carousel slide"></div>
Correct example:
<div id="heroSlider" class="carousel slide"></div> <div id="portfolioSlider" class="carousel slide"></div>
Then each control button must target the correct ID.
data-bs-target="#heroSlider"
or
data-bs-target="#portfolioSlider"
Make sure you added:
Also make sure the Bootstrap JS bundle is loaded correctly.
Creating a slider is easy, but creating a good slider requires attention to design, performance, and usability.
Here are some best practices to follow.
Large images can slow down your website. Before uploading slider images, compress them using an image optimization tool.
Recommended image formats:
A faster slider improves user experience and can help with SEO performance.
Try to use images with the same width and height ratio.
For example, use all images in:
This prevents layout jumping and makes the slider look cleaner.
Do not add too much text inside slider captions. On mobile screens, long text can become hard to read.
A good slider caption should include:
Build Better Websites Create responsive layouts faster with Bootstrap.
Every slider image should have meaningful alt text.
Bad example:
alt="image"
Better example:
alt="Responsive image slider using HTML CSS and Bootstrap"
Alt text helps with accessibility and gives search engines more context about your image.
A slider with too many images can slow down the page and distract users.
For most websites, 3 to 5 slides are enough.
Use only your most important visuals.
Previous and next buttons should be visible on all images. If your images are light, white carousel controls may become hard to see.
You can add a dark background to the controls:
.carousel-control-prev-icon, .carousel-control-next-icon { background-color: rgba(0, 0, 0, 0.7); border-radius: 50%; }
Search engines cannot read text inside images as easily as normal HTML text.
For important headlines, descriptions, and CTAs, use real HTML text inside carousel captions instead of placing all text directly inside the image file.
Always test your Bootstrap image slider on different screen sizes.
Check:
A slider that looks good on desktop may need adjustments for mobile.
Using HTML, CSS, and Bootstrap is a great choice when you are building a custom-coded website. It gives you control over the structure, design, and behavior of the slider.
However, if your website runs on WordPress, manually editing HTML and Bootstrap code may not always be the easiest option.
A WordPress image slider plugin is usually better when you want to:
For example, a regular Bootstrap carousel is useful for showing multiple images one after another. But if you want to compare two images side by side, such as before and after photos, a dedicated before-after image slider plugin is more practical.
This is especially useful for:
For WordPress users, the WP Before After Image Slider plugin can help create interactive before-and-after comparison sliders without writing custom code. Instead of manually building a slider with HTML, CSS, and Bootstrap, you can create a visual comparison slider directly from the WordPress dashboard.
So, the best choice depends on your website type:
If you are comfortable with code, Bootstrap gives you flexibility. If you want a faster WordPress solution, a plugin can save time and simplify the process.
Creating an image slider using HTML, CSS, and Bootstrap is a simple and effective way to improve your website’s visual presentation. With Bootstrap Carousel, you can build a responsive slider with images, captions, controls, indicators, autoplay, and fade effects without writing complex JavaScript.
In this guide, you learned how to:
For new projects, Bootstrap 5 is the recommended option because it is modern, responsive, and does not require jQuery. For WordPress websites, a dedicated slider plugin may be the better choice, especially when you need an easy dashboard-based solution or before-and-after image comparison features.
A well-designed image slider can make your website more engaging, professional, and user-friendly. Just make sure to use optimized images, short captions, responsive styling, and clear navigation controls.
You can create an image slider using Bootstrap’s Carousel component. Add Bootstrap CSS and JavaScript files, create a carousel container, add carousel items with images, and include controls or indicators. You can then use CSS to customize the slider height, image fit, captions, and mobile responsiveness.
Yes, Bootstrap is a good choice for creating responsive image sliders. It provides a ready-made Carousel component with slide transitions, controls, indicators, autoplay, and customization options. It is especially useful for beginners and developers who want to build sliders quickly.
Use Bootstrap’s responsive classes like d-block and w-100 on images. Then add CSS with width: 100%;, height, and object-fit: cover;. You can also use media queries to reduce the slider height on tablets and mobile devices.Example:.carousel-item img {width: 100%;height: 500px;object-fit: cover;}
width: 100%;
height
.carousel-item img {width: 100%;height: 500px;object-fit: cover;}
@media (max-width: 768px) {.carousel-item img {height: 300px;}}
Your Bootstrap carousel may not work because the Bootstrap JavaScript file is missing, the carousel ID does not match the control target, or you are mixing Bootstrap 4 syntax with Bootstrap 5 files. For Bootstrap 5, use attributes like data-bs-ride, data-bs-target, and data-bs-slide.
data-bs-ride
To enable autoplay, add data-bs-ride="carousel" to the carousel container.Example:<div id="mainSlider" class="carousel slide" data-bs-ride="carousel">You can also control slide timing using data-bs-interval.
You can change the slider speed by adding data-bs-interval to each carousel item.Example:<div class="carousel-item active" data-bs-interval="3000">The value is written in milliseconds. For example, 3000 means 3 seconds.
<div class="carousel-item active" data-bs-interval="3000">
Add a carousel-caption div inside each carousel-item.Example:<div class="carousel-caption"> <h5>Slider Heading</h5> <p>Slider description text goes here.</p> </div>You can style the caption with CSS to add background color, padding, border radius, or custom font sizes.
carousel-caption
<div class="carousel-caption"> <h5>Slider Heading</h5> <p>Slider description text goes here.</p> </div>
Add the carousel-fade class to the main carousel container.Example:<div id="mainSlider" class="carousel slide carousel-fade" data-bs-ride="carousel">This changes the default slide animation into a fade transition.
Yes, you can create multiple Bootstrap image sliders on one page. Each carousel must have a unique ID, and its controls and indicators must target that same ID.Example:<div id="heroSlider" class="carousel slide"></div><div id="portfolioSlider" class="carousel slide"></div>
<div id="heroSlider" class="carousel slide"></div><div id="portfolioSlider" class="carousel slide"></div>
This page was last edited on 2 July 2026, at 5:00 pm
Your email address will not be published. Required fields are marked *
Comment *
Name *
Email *
Website
Save my name, email, and website in this browser for the next time I comment.
How many people work in your company?Less than 1010-5050-250250+
By proceeding, you agree to our Privacy Policy