I am trying to center the image with the unique ID of "image" to the right and vertically on the page.
When using PHP, I generate my DIVs in the following way:
echo
"<div class=\"first\">
<div id=\"second\"><label id=\"second_div_label\"></label>
<img id=\"image\" src=\"images/my_image.png\"/>
</div>
<div id=\"third\"></div>
</div>";
The CSS code I am using is:
.first {
display: block;
width: 50%;
height: auto;
margin: 0px auto;
margin-bottom: 15px;
}
#second {
margin-top: 5%;
background-color: #3f51b5;
border-radius: 5px;
font-weight: bold;
padding: 20px;
}
#third {
margin-top: 15px;
border-radius: 5px;
padding: 20px;
}
#image {
width: 35px;
height: 35px;
float: right;
}
Even though I have used float:right
for the image placement, it is not perfectly centered vertically and margin-bottom
is not having the desired effect. Any suggestions on how to resolve this issue?