Bootstrap carousel not working, just images are displayed one by one - html

<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="assets/images/1.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="assets/images/2.jpg" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="assets/images/3.jpg" alt="Third slide">
</div>
</div>
</div>
This is my code. This code just displays images one by one. The slide is not working.

You should add the references on your html like below code snippet.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="assets/images/1.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="assets/images/2.jpg" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="assets/images/3.jpg" alt="Third slide">
</div>
</div>
</div>

Related

Bootstrap 5 carousel of multiple items overlap and active slide larger than previous and next slide

I need a carousel based on attached image. my code below is only showing every active slide. Any idea how to adjust the size of the active slide and a little bit smaller for previous and next slide and overlaps with each other so that the active slide is at the center?
tia
<div id="carouselExampleSlidesOnly" class="carousel slide mt-5 mx-3" data-bs-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="<?php echo IMAGES; ?>/girl-player.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="<?php echo IMAGES; ?>/pixel-player.jpg" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="<?php echo IMAGES; ?>/pixel-player.jpg" alt="Third slide">
</div>
</div>
</div>

My Bootstrap carousel are not giving the slides

I copied a Bootstrap carousel code to understand how it works but the code isn't giving me the desired result. The slides aren't moving.The first slide is just stagnant. Please what do you reccommend I do? Here are the html and css codes. I also included a screenshot of it for more clarification.
html
<div class="carousel-inner">
<div class="carousel-item active" style="background-color: red;">
<img src="..." class="d-block w-100" alt="First slide">
</div>
<div class="carousel-item" style="background-color: yellow;">
<img src="..." class="d-block w-100" alt="Second slide">
</div>
<div class="carousel-item" style="background-color: purple;">
<img src="..." class="d-block w-100" alt="Third slide">
</div>
</div>
</div>
css
.carousel-item {
height: 500px;
}
You need to have the proper parent with the appropriate id and data-ride that correlates with Bootstrap. Then you need to add the relative JS and CSS for Bootstrap 4.
.carousel-item {
height: 500px;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active" style="background-color: red;">
<img src="..." class="d-block w-100" alt="First slide">
</div>
<div class="carousel-item" style="background-color: yellow;">
<img src="..." class="d-block w-100" alt="Second slide">
</div>
<div class="carousel-item" style="background-color: purple;">
<img src="..." class="d-block w-100" alt="Third slide">
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/jquery#3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-fQybjgWLrvvRgtW6bFlB7jaZrFsaBXjsOMm/tB9LTS58ONXgqbR9W8oWht/amnpF" crossorigin="anonymous"></script>
Add this code inside "head" tag of your .html file.
Why do you need to add this? The answer is whenever you are using a 3rd party library either you need to install it in your project or use its CDN to make it work.
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>

How to get multiple slider

I want to have automatic multiple sliders and they should be side by side, each sliding in different periods of time.
I am a beginner coder and tried to make this work by trying myself and searching for solutions but nothing works, it would be great if i got the code how to do it
If you add bootstrap to your code you can use this:
<div id="carouselExampleSlidesOnly" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="..." class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="..." class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="..." class="d-block w-100" alt="...">
</div>
</div>
</div>
Add the desired picture's location to img tag's src attribute and it will automaticly start to slide.
Note: To add bootstrap check this https://getbootstrap.com/docs/5.0/getting-started/introduction/

Bootstrap slider not giving the expected result

I was trying to make a carousel for my website using Bootstrap, but the carousel just gives me this icon:
My Google dev tools did not give me errors, the same can be said for Pycharm; no errors. Here is my code:
<div class="container">
<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item active">
<img src="C:\Users\pert\PycharmProjects\milestonewebsite\images\one.jpg" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="C:\Users\pert\PycharmProjects\milestonewebsite\images\two.jpg" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="C:\Users\pert\PycharmProjects\milestonewebsite\images\three.jpg" class="d-block w-100" alt="...">
</div>
</div>
</div>
</div>
ok, i found out the problem, for some reson, my computer only accepted gif links, now it is working properly

Adding URL link to a picture

So I have this carousel making my website 'fancy'. But I want to link the individual pictures to the websites it should got to once clicked on.
The following is my code:
<div class="carousel-item active">
<img class="d-block w-100" src="images/ncaa-bb-banner-1920x500 (1).png" alt="First slide" >
<div class="carousel-caption d-none d-md-block" >
<h5 href="sportsevents.php">Sport Events</h5>
</div>
</div>
I have added href="sportsevents.php" to the first div, img and the second div, but it doesn't seem to link up. Am I having a brain fart and missing something or is there something else I should do?
You can do like this and get desired result.
<div class="carousel-item active">
<img class="d-block w-100" src="images/ncaa-bb-banner-1920x500 (1).png" alt="First slide" >
<div class="carousel-caption d-none d-md-block" >
<h5>Sport Events</h5>
</div>
</div>