I have an image inside div like this
<div class="MainDiv">
<img src="/Content/Images/116.gif" alt="Comcast: West Region">
</div>
So, I would like to know How can I vertically align center to an image inside div using CSS?
You can align image centrally inside a div using this code
.Main{
display: flex;
align-items: center;
}
.Main img {
/* change it accordingly */
max-height: 25px;
}
/* Styling stuff not needed for demo*/
.Main{
height: 24px;
}
You can keep your HTML as it just add the above CSS in your stylesheet it should work
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly