I am currently working on HTML code that is intended to display 3 divs side by side using Bootstrap syntax:
.main-background {
background-color: white;
padding-top: 40px;
padding-right: 20px;
padding-bottom: 40px;
padding-left: 20px;
}
.main-Image {
display: flex;
padding-bottom: 40px;
-webkit-box-pack: center;
justify-content: center;
-webkit-box-align: center;
align-items: center;
background-color: white;
box-sizing: border-box;
}
.main-h3 {
align-items: center;
background-color: #fff;
font-family: Lora, sans-serif;
color: #162b3b;
font-size: 24px;
line-height: 1.5em;
font-weight: 400;
text-align: center;
display: flex;
padding: 10px 40px 40px;
-webkit-box-align: center;
box-sizing: border-box;
}
.main-footer {
font-family: 'Source Sans Pro', sans-serif;
color: #162b3b;
font-size: 18px;
line-height: 24px;
text-align: center;
box-sizing: border-box;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<div class="row ">
<div class="col-xl-4 main-background">
<div class="main-Image">
<img src="~/img/How_It_Works_Personalized-1.jpg" loading="lazy" sizes="(max-width: 479px) 93vw, 250px" width="250" />
</div>
<div class="main-h3">
1. Personalized Recommendations
</div>
<div class="main-footer">
Receive practice-specific, data-driven recommendations and care plans
</div>
</div>
<div class="col-xl-4 main-background">
<div class="main-Image">
<img src="~/img/How_It_Works_Personalized-1.jpg" loading="lazy" sizes="(max-width: 479px) 93vw, 250px" width="250" />
</div>
<div class="main-h3">
1. Personalized Recommendations
</div>
<div class="main-footer">
Receive practice-specific, data-driven recommendations and care plans
</div>
</div>
<div class="col-xl-4 main-background">
<div class="main-Image">
<img src="~/img/How_It_Works_Personalized-1.jpg" loading="lazy" sizes="(max-width: 479px) 93vw, 250px" width="250" />
</div>
<div class="main-h3">
1. Personalized Recommendations
</div>
<div class="main-footer">
Receive practice-specific, data-driven recommendations and care plans
</div>
</div>
</div>
At the moment, the 3 divs are displaying aligned together like this:
https://i.sstatic.net/z4tlM.png
Now I want to introduce some horizontal space between these divs without causing the last div to wrap onto a new row. If I try adding margin-left
and margin-right
to the middle divs, it results in the last div moving to a new line!