I would like to vertically center the image in the below HTML, so that it is vertically-center to the div it is next to (“rtUpdateContentDiv”). Both the img and div are inside a parent container, “rtUpdateContainerDivActive”.
<div class="rtUpdateContainerDivActive">
<img class="statusImg" src="images/icons/Knob-Valid-Green.png">
<div class="rtUpdateContentDiv">
<span class="rtBlueHighlight">date and time:</span>
ipsum lorem text here
</div>
</div>
here is the css of the image so far:
.statusImg
{
position: absolute;
margin-top: auto;
margin-bottom: auto;
vertical-align: middle;
padding-left: 3px;
padding-top: 3px;
}
and of the container:
.rtUpdateContainerDivActive
{
background-color: #90ee90;
margin-top: 1%;
position: relative;
min-height: 38px;
}
The parent needs to remain relative.
How can I vertically-center the image (38px x 38px)?
Thank you for any help!
Solution1:
Solution2:
hope it will help…