I am a super beginner in HTML and CSS. It was actually aligned and balanced until I put text inside each three divs and photos become like this, unbalanced even I use the same width and height:
These are the codes:
#wrapper{
display:flex;
width: 100%;
justify-content: space-around;
}
.party{
display:inline-flex;
flex-direction: column;
align-items: center;
justify-content: space-around;
padding: 2%;
}
.party img{
border: solid black 2px;
padding: 0.3%;
margin: 2%;
max-width: 100%;
max-height: 100%;
}
input[type = button] {
background-color: black;
padding: 10px 20px;
color: white;
margin: 2px 1px;
cursor: pointer;
}
<div id="wrapper">
<div class = "party">
<img src = "Images/birthday_1.jpg">
<h3 style = "font-size: 2vw;">Party Events</h3>
<p style = "font-size: 1.5vw;"> Want flower decoration for your birthday, ceremonies, baby showers and any party events? Consult to our florist now!</p>
<input type = "button" value = " Shop Now "/>
</div>
<div class ="party">
<img src = "Images/wedding_1.jpg">
<h3 style = "font-size: 2vw;"> Wedding Events </h3>
<p style = "font-size: 1.5vw;">We offer free consultation for a bride-to-be. Call our store to make an appointment on <b>+64 85459 3943</b></p>
<input type = "button" value = " Shop Now "/>
</div>
<div class = "party">
<img src = "Images/sympathy.jpg">
<h3 style = "font-size: 2vw;">Sympathy</h3>
<center><p style = "font-size: 1.5vw;"> Fresh flowers that express heartfelt thoughts and sincere condolences. Talk to our dedicated team by phone or come in to meet with our flourist in a private consultation.</p></center>
<input type = "button" value = " Shop Now "/>
</div>
</div>
This is my ideal result:
** What should I do? Any recommendations?**
When using flex to put elements on the same row the default behavior is for the elements to adapt to their content's width. To fix this you can simply set a width of each element, I chose 33.33% because we have 3 elements, so 100 / 3 = 33.33.
As for the images, there's a trick to lock them to a responsive square regardless of the image size or ratio, you need to put the image into a container, set the container's height to 0 and the padding-top (or bottom) to 100%, since the percentage is based on it's width it will make the container a perfect square.
Once you have that square you can use position: absolute; on the image itself to position it relative to the container, and then use object-fit: cover, which basically tells the browser to always fill the container with a given element. it's a bit complicated but I hope it makes sense, you said you're still a beginner so don't worry if it's not super clear for now, you'll get to it eventually. If you have other questions drop them in the comments