I have four divs sitting inside a parent flexbox.
What is confusing me is how I can get the images within the flex items to center vertically and horizontally. I thought the following would do it:
justify-content: center; align-items: center;
Adding these to the flexbox parent would work but it doesnt seem to have the effect I am looking for.
My CSS is as follows:
.flex-container {
display: flex;
flex-wrap: nowrap;
width: 650px;
}
.flex-container > div {
width: 100px;
margin: 10px;
text-align: center;
line-height: 75px;
font-size: 30px;
align-items: center;
justify-content: center;
}
.div-1 {
flex: 2;
}
.div-2 {
flex: 1;
}
.div-3 {
flex: 1;
}
.div-4 {
flex: 1;
}
.img {
height: 55px;
}
.bookit_button {
background-color: #4CAF50;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
My HTML is as follows:
<div class="flex-container">
<div class="div-1">
<button class="bookit_button">Book An Appointment</button>
</div>
<div class="div-2"><img src="images/facebook_icon.png" class="img"/></div>
<div class="div-3"><img src="images/instagram_icon.png" class="img" /></div>
<div class="div-4"><img src="images/twitter_icon.png" class="img" /></div>
Ultimately, the goal is to end up with this: