So I have 3 same class divs and I want them to be evenly spaced in the same line.
HTML:
<div class="group-4">
<div class="group-5">
<div class="text-wrapper-5">Hesapla</div>
<div class="group-6">
<div class="img-wrapper"><img class="img" src="img/case.svg"></div>
<div class="text-wrapper-6">Some Context</div>
</div>
<p class="p">
A tristique facilisi gravida at felis. Sed ornare arcu, tortor hendrerit etiam vulputate
libero tellus. Etiam nu
</p>
</div>
</div>
CSS:
.group-4 {
position: relative;
display: inline-flex;
height: 186px;
justify-content: space-evenly;
}
.group-5 {
position: relative;
width: 316px;
height: 186px;
}
.text-wrapper-5 {
position: relative;
top: 162px;
left: 49px;
font-family: "Inter-Bold", Helvetica;
font-weight: 700;
color: #ff611e;
font-size: 16px;
letter-spacing: 0.46px;
line-height: 24px;
white-space: nowrap;
}
.group-6 {
position: relative;
display: inline-flex;
width: 314px;
height: 40px;
top: 0;
left: 0;
}
Here is a photo of the current site.
photo
I’m not really experienced in CSS but I tried inline-flex display mode which didn’t help much.
2
Answers
Set the outer div containing the 3 divs to be display flex. set another property on this outer div which is flexDirection: row. Then add another property justifyContent: center (or set it to space-evenly) and alignItems: center.
You can solve this pretty quickly with flexbox. You probably want to remove
position: relative
from.group-5
, and then change.group-4
todisplay: flex
and maybe addalign-items: center
, but that might not be needed. I would also remove theposition
anddisplay
properties from.group-6
as I don’t think those are doing anything for you currently. You did not post all your HTML, but assuming that.group-5
repeats 3 times, making those changes will give you what you want. Unrelated to your question, but you should always use a 100% safe fallback font when you declare yourfont-family
stack (like in.text-wrapper-6
, usually the font type likesans-serif
. Take a look here:If you want a better look at this where you can expand the screen and actually see it demo’d, you can check out my codepen demo here or you can view the fullscreen Codepen example without the code.
As a final note, I would also recommend trying to come up with more descriptive names for your classes than just
.group-#
. That can get pretty confusing and giving them better names will remove some of the mental overhead when you’re trying to style them.Hope this helps!