I am creating the page using flex, as I am in the learning process
I want the content in the parent banner class to be in the middle of a div which has 3 childs class="quick-link" class="carousel slide" class="article"
Currently, they are at the left of an div
When I add an image in the content, the div are not occupying the full width of a div.
Can it be because I have given some width to an image?
I have given the d-flex to the main parent in HTML structure and trying to apply the justify-content: center; so that all the child in the parent get in the middle
Can anyone tell me, what am I doing wrong?
HTML Code:
<main>
<div class="main-container">
<!-- section 1 - Banner -->
<div class="banner d-flex">
<div class="quick-link">
<p>QUICKLINK</p>
<p>Fashion & Accessories</p>
<p>Spa & Massage</p>
</div>
<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="images/banner-mobile.jpg" alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="images/banner-mobile.jpg" alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block w-100" src="images/banner-mobile.jpg" 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="article">
<div class="sony-tv banner-img">
<img src="images/free.png" alt="" style="width:40%;">
</div>
<div class="samsung banner-img">
<img src="images/free.png" alt="" style="width:40%;">
</div>
<div class="beat-phone banner-img">
<img src="images/free.png" alt="" style="width:40%;">
</div>
</div>
</div>
</div>
</main>
Attaching screenshot how I am getting output: enter image description here
Using display flex, sometimes width works according to content so try using width 100%.
CSS