I'm having trouble with using flex to align an image and text horizontally on the same line. I have tried align-items: center
, but it did not work as expected.
Using align-items: flex-start;
seemed to somewhat align them horizontally, but it's not quite precise enough for what I need.
I am unsure of why this is happening. Any help in achieving a precise horizontal alignment would be greatly appreciated. I attempted to add style="vertical-align:middle;"
to the <img>
tag, but that also did not work as intended.
.entrepreneur {
display: flex;
align-items: flex-start;
vertical-align: middle;
}
.entrepreneur img {
width: 35px;
margin-top: 0;
margin-bottom: 0;
}
.entrepreneur #text {
margin-left: 10px;
margin-top: 0;
margin-bottom: 0
}
<div class="entrepreneur">
<img src="img/Mark.jpg" alt="">
<p id="text">Mark</p>
</div>