I followed the professor's instructions correctly, however this is the result. Someone can help me please?
My example
This is how the professor has done:
Professor's carousel
<div class="container"><!--Start row contents-->
<div class="row row-content">
<div class="col">
<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="img/uthappizza.png" class="d-block img-fluid" alt="uthappizza">
</div>
<div class="carousel-item">
<img src="img/buffet.png" class="d-block img-fluid" alt="buffet">
</div>
<div class="carousel-item">
<img src="img/alberto.png" class="d-block img-fluid" alt="alberto">
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" 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="#carouselExampleIndicators" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</div>
</div>
I ran your code and it's working. I guess you mean why in your professor's version you can see some pictures on the carousel, but not in your version. You can easily do that by adding captions to your slides with the .carousel-caption element within any .carousel-item. You can read more about it on the following page:
https://getbootstrap.com/docs/5.1/components/carousel/
<div class="container">
<!--Start row contents-->
<div class="row row-content">
<div class="col">
<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0"
class="active" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1"
aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2"
aria-label="Slide 3"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="img/uthappizza.png" class="d-block img-fluid" alt="uthappizza">
<div class="carousel-caption d-none d-md-block text-black">
<h5>First slide label</h5>
<p>Some representative placeholder content for the first slide.</p>
</div>
</div>
<div class="carousel-item">
<img src="img/buffet.png" class="d-block img-fluid" alt="buffet">
<div class="carousel-caption d-none d-md-block text-black">
<h5>First slide label</h5>
<p>Some representative placeholder content for the first slide.</p>
</div>
</div>
<div class="carousel-item">
<img src="img/alberto.png" class="d-block img-fluid" alt="alberto">
<div class="carousel-caption d-none d-md-block text-black">
<h5>First slide label</h5>
<p>Some representative placeholder content for the first slide.</p>
</div>
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators"
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="#carouselExampleIndicators"
data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</div>
</div>
Related
I made a carousel, when I touch these buttons, I want it to go, but it doesn't. How can I do this?
Code:
<div class="container mt-4">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1">1</button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2">2</button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3">3</button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="assets/img/black.png" width="100%" height="300px" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="assets/img/black.png" width="100%" height="300px" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="assets/img/black.png" width="100%" height="300px" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" 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="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
Here's one that's working copied from the official documentation.
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
<div id="carouselExampleIndicators" class="carousel slide">
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="https://fastly.picsum.photos/id/870/800/400.jpg?hmac=RVmKPEQDqKbI8SLlLbkfaMuxiJVQrPuMoyv7vuxPbL8" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="https://fastly.picsum.photos/id/494/800/400.jpg?hmac=aPwfyKjkUw_ivDNPavHejXC1zg_pSk3LgmPToXqbKOA" class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="https://fastly.picsum.photos/id/243/800/400.jpg?hmac=IEsjm30yORWR_y11K0bSLyasctvraSJ_sgNgSNNqQk8" class="d-block w-100" alt="...">
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" 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="#carouselExampleIndicators" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
Iam trying to bring the carousel to my liking but have some issues. I have set my whole page to be center aligned. When iam trying to resize my carousel images it isnt at the center anymore.
<div class="container-fluid">
<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-indicators">
<button
type="button"
data-bs-target="#carouselExampleIndicators"
data-bs-slide-to="0"
class="active"
aria-current="true"
aria-label="Slide 1"
></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="3" aria-label="Slide 3"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="4" aria-label="Slide 4"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="5" aria-label="Slide 5"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="images/Full Stack Developer.png" class="d-block w-100" alt="full-stack-developer-logo" />
</div>
<div class="carousel-item">
<img src="images/Microsoft Office.png" class="d-block w-100" alt="Microsoft-Office-Suite-logo" />
</div>
<div class="carousel-item">
<img src="images/Adobe Suite.png" class="d-block w-100" alt="Adobe-Suite-logo" />
</div>
<div class="carousel-item">
<img src="images/3dsmaxsuite.png" class="d-block w-100" alt="3dsmax-suite-logo" />
</div>
<div class="carousel-item">
<img src="images/Pixologic Zbrush.png" class="d-block w-100" alt="Pixologic-zbrush-logo" />
</div>
<div class="carousel-item">
<img src="images/Unreal Engine Suite.png" class="d-block w-100" alt="unreal-engine-logo" />
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" 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="#carouselExampleIndicators" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</div>
Im having problem centering the img to its place using bootstrap 5 img slider carousel:
<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="../images/1.jpg" class="w-25" alt="...">
</div>
<div class="carousel-item">
<img src="../images/2.jpg" class="w-25" alt="...">
</div>
<div class="carousel-item">
<img src="../images/3.jpg" class="w-25" alt="...">
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" 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="#carouselExampleIndicators" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
I took the code from: bootstrap Carousel
Here, You have set 25% with of carousal item image. So, You will need to add text align center for carousal item. You can use simple text-center bootstrap class for that.
Your <div class="carousel-inner"> code should be as below:
<div class="carousel-inner">
<div class="carousel-item text-center active">
<img src="../images/1.jpg" class="w-25" alt="...">
</div>
<div class="carousel-item text-center">
<img src="../images/2.jpg" class="w-25" alt="...">
</div>
<div class="carousel-item text-center">
<img src="../images/3.jpg" class="w-25" alt="...">
</div>
</div>
select the div of each image with their class in your CSS and write text-align:center; this way it gets centered. (Simply use the code I sent)
.carousel-item{
text-align: center;
}
I have a problem with the position of content with bootstrap i wondering how to make the caption to center of the carousel
<div id="carouselExampleCaptions" class="carousel slide" data-bs-ride="false">
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="./img/balaidikmen.jpg" class="d-block w-100 d-flex" alt="...">
<div class="col-md-3 col-sm-6 hero-feature">
<div class="thumbnail">
<img src="http://placehold.it/800x500" alt="">
<div class="carousel-caption d-none d-md-block " style="background-color: red;">
<h5>Second slide label</h5>
<p>Some representative placeholder content for the second slide.</p>
</div>
</div>
</div>
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleCaptions" 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="#carouselExampleCaptions" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
So I am putting together a website for a friend of mine who is a hair dresser and she wants a quick, flat-rate type of website so I decided bootstrap would be the avenue I take for the job.
I put together the navigation and the carousel just fine, but when I tried adding a card it placed the card almost in the direct middle of the carousel. I actually liked this look but was still confused as to how it happened and then I tried adding a footer to the landing page and now the footer doesn't show up, when I test the website for mobile devices the footer shows up along with a ton of unwanted white space.
I included the carousel to show this is how my file is structured and to help see if this will bring a solution
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<div id="carouselContainer">
<div class="row">
<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="imgs/hair_stylist.jpg" class="d-block w-100" alt="" />
</div>
<div class="carousel-item">
<img src="imgs/hair_dryer-2.webp" class="d-block w-100" alt="" />
</div>
<div class="carousel-item">
<img src="imgs/hair_dryer.jpg" class="d-block w-100" alt="" />
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" 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="#carouselExampleIndicators" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</div>
</div>
<div class="card text-white text-center bg-dark mb-3" id="aboutSection">
<div class="card-body">
<h5 class="card-title">Insert Welcome Message</h5>
<p class="card-text">
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
</p>
<p class="card-text">
<small class="text-muted">Last updated 2/22/2021</small>
</p>
</div>
</div>
<div class="row">
<footer class="bg-light text-center text-lg-start">
<!-- Copyright -->
<div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.2)">
© 2020 Copyright:
<a class="text-dark" href="https://mdbootstrap.com/">MDBootstrap.com</a
>
</div>
<!-- Copyright -->
</footer>
</div>
Your carousel and footer were both inside 'row', which was not required. I think that is the reason for overlap and white space.
You should only use class="row" if you want to divide a section into a bunch of columns as it applies css flex. Also use it inside a container/col as it also applies negative margin of 15px.
You also need jquery and bootstrap.js for the carousel navigation to work.
https://jsfiddle.net/deo8gq6t/
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="https://via.placeholder.com/1920x1080.png" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://via.placeholder.com/1920x1080.png" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://via.placeholder.com/1920x1080.png" alt="Third slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators" 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="#carouselExampleIndicators" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<div class="card text-white text-center bg-dark mb-3" id="aboutSection">
<div class="card-body">
<h5 class="card-title">Insert Welcome Message</h5>
<p class="card-text">
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
</p>
<p class="card-text">
<small class="text-muted">Last updated 2/22/2021</small>
</p>
</div>
</div>
<div>
<footer class="bg-light text-center text-lg-start">
<!-- Copyright -->
<div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.2)">
© 2020 Copyright:
<a class="text-dark" href="https://mdbootstrap.com/">MDBootstrap.com</a>
</div>
<!-- Copyright -->
</footer>
</div>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
you have to remove mb-3 class from this aboutSection and add col-md-12 class add in footer for full width.
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<div id="carouselContainer">
<div class="row">
<div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-indicators">
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="1" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="imgs/hair_stylist.jpg" class="d-block w-100" alt="" />
</div>
<div class="carousel-item">
<img src="imgs/hair_dryer-2.webp" class="d-block w-100" alt="" />
</div>
<div class="carousel-item">
<img src="imgs/hair_dryer.jpg" class="d-block w-100" alt="" />
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleIndicators" 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="#carouselExampleIndicators" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</div>
</div>
<div class="card text-white text-center bg-dark " id="aboutSection">
<div class="card-body">
<h5 class="card-title">Insert Welcome Message</h5>
<p class="card-text">
This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
</p>
<p class="card-text">
<small class="text-muted">Last updated 2/22/2021</small>
</p>
</div>
</div>
<div class="row">
<footer class="col-md-12 bg-light text-center text-lg-start">
<!-- Copyright -->
<div class="text-center p-3" style="background-color: rgba(0, 0, 0, 0.2)">
© 2020 Copyright:
<a class="text-dark" href="https://mdbootstrap.com/">MDBootstrap.com</a
>
</div>
<!-- Copyright -->
</footer>
</div>