My website utilizes Bootstrap along with a carousel slider, which is functioning properly. However, I am encountering an issue when the slider transitions from right to left. It briefly displays a white space between slides, which I wish to eliminate. I want the second image to seamlessly appear immediately after the first one without any gap in between.
I aspire for my slider to function like this demo
.carousel-item {
perspective: 1000px;
transform-style: preserve-3d;
}
.carousel-item img {
object-fit: cover;
width: 100%;
height: 100%;
}
.carousel-inner {
display: flex;
flex-wrap: nowrap;
/* Prevent items from wrapping */
gap: 1rem;
/* Add some space between carousel items */
overflow: hidden;
/* Hide the overflow to prevent extra spacing */
perspective: 1000px;
}
.carousel-item {
flex: 0 0 calc(33.333333% - 1rem);
/* Calculate the width with gap */
transform: translateZ(-200px);
backface-visibility: hidden;
}
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="52303d3d26212620332212677c617c61">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet">
<div id="carouselExample" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://placehold.co/800x400" class="d-block w-100" alt="Image 1">
</div>
<div class="carousel-item">
<img src="https://placehold.co/800x400" class="d-block w-100" alt="Image 2">
</div>
<div class="carousel-item">
<img src="https://placehold.co/800x400" class="d-block w-100" alt="Image 3">
</div>
<!-- Incorporate more carousel items as needed -->
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExample" 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="#carouselExample" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b1d3dedec5c2c5c3d0c1f1849f829f82">[email protected]</a>/dist/js/bootstrap.min.js"></script>
You may notice the presence of white space in the current setup, but I aim to have the subsequent image appear seamlessly after the previous one in my carousel.