I have been trying to add a carousel to my landing page and come out with a problem, i am able to see the first image of the carousel but the template literally does not slide to the next image. I have copied the template from bootstrap-carousel, i can see the navigators, data-bs-interval not responding, too. My Bootstrap version is 5.1.3. I even tried to add references for Jquery even though I know it's not required. Thank you in advance.
References:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
HTML and CSS codes;
#carouselExampleCaptions img{
max-width: 700px;
margin: auto;
//alignment and resizing
}
<div id="carouselExampleCaptions" data-bs-ride="carousel" data-bs-interval="2000">
<div >
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="0" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="1" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
<div >
<div >
<img src="/jpg/wood_12.jpg" alt="...">
<div >
<h5>Özel Üretim</h5>
<p>Masa tasarımı ve boyutlarını sizin tercihinize göre yapılandırıyoruz</p>
</div>
</div>
<div >
<img src="/jpg/wood_10.jpg" alt="...">
<div >
<h5>Second slide label</h5>
<p>Some representative placeholder content for the second slide.</p>
</div>
</div>
<div >
<img src="/jpg/wood_11.jpg" alt="...">
<div >
<h5>Third slide label</h5>
<p>Some representative placeholder content for the third slide.</p>
</div>
</div>
</div>
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide="prev">
<span aria-hidden="true"></span>
<span >Previous</span>
</button>
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide="next">
<span aria-hidden="true"></span>
<span >Next</span>
</button>
</div>
CodePudding user response:
I copied your code to a Bootsrap 5 page that I currently have open and the slides do seem to work OK. I haven't changed anything except to remove d-none
from the carousel-caption
's. I am fairly sure that wasn't preventing the slideshow though.
data-bs-interval
needs to go on each slide. On each of the Divs which have
CodePudding user response:
I just copy pasted your code to a codepen and it seems working fine.
are you sure you added links to jquery, bootstrap css and bootstrap js to ur project?
You can check the codepen here
#carouselExampleCaptions img {
max-width: 700px;
margin: auto;
//alignment and resizing
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg OMhuP IlRH9sENBO0LRn5q 8nbTov4 1p" crossorigin="anonymous"></script>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div id="carouselExampleCaptions" data-bs-ride="carousel" data-bs-interval="2000">
<div >
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="0" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="1" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
<div >
<div >
<img src="https://images.unsplash.com/photo-1564419320408-38e24e038739?ixlib=rb-1.2.1&ixid=MnwxMjA3fDF8MHxlZGl0b3JpYWwtZmVlZHwxfHx8ZW58MHx8fHw=&auto=format&fit=crop&w=500&q=60" alt="...">
<div >
<h5>Özel Üretim</h5>
<p>Masa tasarımı ve boyutlarını sizin tercihinize göre yapılandırıyoruz</p>
</div>
</div>
<div >
<img src="https://images.unsplash.com/photo-1646121575186-fe136178cff2?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwxM3x8fGVufDB8fHx8&auto=format&fit=crop&w=500&q=60" alt="...">
<div >
<h5>Second slide label</h5>
<p>Some representative placeholder content for the second slide.</p>
</div>
</div>
<div >
<img src="https://images.unsplash.com/photo-1646100960029-967036496807?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxlZGl0b3JpYWwtZmVlZHwxN3x8fGVufDB8fHx8&auto=format&fit=crop&w=500&q=60" alt="...">
<div >
<h5>Third slide label</h5>
<p>Some representative placeholder content for the third slide.</p>
</div>
</div>
</div>
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide="prev">
<span aria-hidden="true"></span>
<span >Previous</span>
</button>
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide="next">
<span aria-hidden="true"></span>
<span >Next</span>
</button>
</div>