How to center div that contains an image within a div?

前端 未结 3 1252
我在风中等你
我在风中等你 2020-12-19 17:55

I need to center a image inside a div both vertically and horizontally. I am using the display inline-block property.

HTML

3条回答
  •  孤城傲影
    2020-12-19 18:33

    You can put the image into a table like this:

      

    And then use this in your CSS:

    .image-container {
       vertical-align: middle;
       text-align: center;
    }
    

    JSFiddle

提交回复
热议问题