+ 1
Maintaining Align
I’m trying to center an image while also having it in a div. The issue is, though, when I don’t add height or width properties to the div, it stretches the whole page, but the image is centered. Though when I do apply height and width to the div, the image automatically becomes un-centered and the div stays at the left. How do I center the image AND the div (the div having width and height properties added) without messing with anything else? Code: codepen.io/Technical/pen/yveqPP
3 Respostas
+ 7
Usually I'm using:
HTML:
<div>
<img src="link" alt="description"/>
</div>
CSS:
div {
display: block;
margin: auto;
}
+ 7
Not at all😊
+ 1
It worked - thank you!