I was exploring the basics of Bootstrap and everything seemed to worked fine(the very basic stuff, tables, col, etc.). However, I tried to make a carousel by following the example on the bootstrap website and it didn't work. The carousel appeared fine with everything but the next and prev buttons did nothing.
So I just copied the example on the website directly and the same thing happens, everything is there but non-functional. I was using the bootstrap files given to me by WebStorm but I changed it to the CDN links as a troubleshooting step to no avail.
I tried in Edge and Chrome too. [edit]I also tried a suggestion that I found on SO to change the anchor tags to button tags for the buttons but it didn't work[/edit]
Am I missing a dependency somewhere? I believe I have everything I need:
- bootstrap.min.css
- bootstrap.bundled.min.js
- jquery.min.js
Thank you.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
<title>Title</title>
</head>
<body>
<div id="carouselExampleIndicators" data-ride="carousel">
<ol >
<li data-target="#carouselExampleIndicators" data-slide-to="0" ></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div >
<div >
<img src="https://placeimg.com/1080/500/animals" alt="First slide">
<div >
<h5>My Caption Title (1st Image)</h5>
<p>The whole caption will only show up if the screen is at least medium size.</p>
</div>
</div>
<div >
<img src="https://placeimg.com/1080/500/arch" alt="Second slide">
</div>
<div >
<img src="https://placeimg.com/1080/500/nature" alt="Third slide">
</div>
</div>
<button data-target="#carouselExampleIndicators" role="button" data-slide="prev">
<span aria-hidden="true"></span>
<span >Previous</span>
</button>
<button data-target="#carouselExampleIndicators" role="button" data-slide="next">
<span aria-hidden="true"></span>
<span >Next</span>
</button>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj 3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
</body>
</html>
CodePudding user response:
Like @CBroe pointed out in the comment there was a version mismatch, the code was for Bootstrap 4.0 and the Bootstrap version I was using was 5.0.