Center image using text-align center?

后端 未结 24 1628
终归单人心
终归单人心 2020-11-21 17:53

Is the property text-align: center; a good way to center an image using CSS?

img {
    text-align: center;
}
24条回答
  •  执念已碎
    2020-11-21 18:18

    That doesn't always work... if it doesn't, try:

    img {
        display: block;
        margin: 0 auto;
    }
    

提交回复
热议问题