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>
Related
when it is in mobile resolution, the carousel items go down
enter image description herebootstrap carousel
enter image description here
<div class="container">
<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>
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="1" aria-label="Slide 2"></button>
</div>
<div class="carousel-inner">[enter image description here][1]
<div class="carousel-item active">
<img src="/img/banner 1.png" class="d-block w-100" alt="banner 1">
<div class="carousel-caption d-md-block">
<h5>Velocida</h5>
<p>Coleta e entrega rápida de encomendas.</p>
<button type="button" class="btn btn-light">Serviços</button>
</div>
</div>
<div class="carousel-item">
<img src="img/banner 2.png" class="d-block w-100" alt="banner 2">
<div class="carousel-caption d-md-block">
<h5>Segurança</h5>
<p>A logística ideal para levar seus pedidos com segurança.</p>
<button type="button" class="btn btn-light">Serviços</button>
</div>
</div>
</div>
Is this what you want?
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.2/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.6.2/dist/js/bootstrap.bundle.min.js"></script>
<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>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-100" src="https://picsum.photos/200/100" class="d-block w-100" alt="First slide">
<div class="carousel-caption d-md-block">
<h5>Velocida</h5>
<p>Coleta e entrega rápida de encomendas.</p>
<button type="button" class="btn btn-light">Serviços</button>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://picsum.photos/200/100" class="d-block w-100" alt="Second slide">
<div class="carousel-caption d-md-block">
<h5>Segurança</h5>
<p>A logística ideal para levar seus pedidos com segurança.</p>
<button type="button" class="btn btn-light">Serviços</button>
</div>
</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>
the carousel shows me the first image that's it , it is like the slider is bloked, the buttons not working either
<main>
<div id="slider" class="carousel slide" data-mdb-ride="carousel">
<div class="carousel-inner" >
<div class="carousel-item active">
<img src="images/hero1.png" class="d-block w-100" alt="Wild Landscape">
</div>
<div class="carousel-item ">
<img src="images/hero2.jpg" class="d-block w-100" alt="Camera">
</div>
<div class="carousel-item ">
<img src="images/hero3.jpg" class="d-block w-100" alt="Exotic Fruits">
</div>
</div>
<button class="carousel-control-prev" type="button" data-mdb-target="#slider" data-mdb-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-mdb-target="#slider" data-mdb-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</main>
<script src="js/bootstrap.min.js"></script>
Attention to the bootstrap version used.
In version 5.2 for example you need to use as:
data-bs-ride data-bs-target data-bs-slide
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/js/bootstrap.bundle.min.js"></script>
<main>
<div id="slider" class="carousel slide" data-bs-ride="carousel">
<div class="carousel-inner" >
<div class="carousel-item active">
<img src="images/hero1.png" class="d-block w-100" alt="Wild Landscape">
</div>
<div class="carousel-item ">
<img src="images/hero2.jpg" class="d-block w-100" alt="Camera">
</div>
<div class="carousel-item ">
<img src="images/hero3.jpg" class="d-block w-100" alt="Exotic Fruits">
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#slider" 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="#slider" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
</main>
Hope this helps.
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>
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>