Is the property text-align: center;
a good way to center an image using CSS?
img {
text-align: center;
}
I discovered that if I have an image and some text inside a div
, then I can use text-align:center
to align the text and the image in one swoop.
HTML:
Picture #1
CSS:
.picture-group {
border: 1px solid black;
width: 25%;
float: left;
height: 300px;
#overflow:scroll;
padding: 5px;
text-align:center;
}
CodePen: https://codepen.io/artforlife/pen/MoBzrL?editors=1100