why isn't there any space at the ends for child elements of this flexbox container?
I was following a tutorial to make a website, and in a particular section we had to make a flexbox container with three child elements. I have checked and re-checked my code, it is the same as the video but there isn't any space at the right and left end of the flex container. Why isn't is working? (I've given the CSS code below)
.row {
margin-top: 5%;
display: flex;
justify-content: space-between;
}
.course-col {
flex-basis: 31%;
background: #fff3f3;
border-radius: 10px;
margin-bottom: 5%;
padding: 20px 12px;
box-sizing: border-box;
transition: 0.5s;
}
/* this is the title of the child elements*/
h3 {
text-align: center;
font-weight: 600;
margin: 10px 0;
}
.course-col:hover {
box-shadow: 0 0 20px 0px rgba(0, 0, 0, 0.2);
}
@media (max-width: 700px) {
.row {
flex-direction: column;
}
}
This is the HTML code :
<!-- COURSES !-->
<section class="course">
<h1>Courses We Offer</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
<div class="row">
<div class="course-col">
<h3>Intermediate</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div class="course-col">
<h3>Degree</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
<div class="course-col">
<h3>Post Graduation</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</div>
</section>
Solution 1:
Try only this:
.row {
margin-top: 5%;
display: flex;
justify-content: space-around;/* here */
}
Also:
@media (max-width: 700px) {
.row {
flex-direction: column;
margin: auto 10px; /* here */
}
}