Vertically align an image inside a div with responsive height

后端 未结 10 1652
遇见更好的自我
遇见更好的自我 2020-11-22 02:47

I have the following code which sets up a container which has a height that changes with the width when the browser is re-sized (to maintain a square aspect ratio).

10条回答
  •  伪装坚强ぢ
    2020-11-22 03:36

    Try this one

      .responsive-container{
              display:table;
      }
      .img-container{
              display:table-cell;
              vertical-align: middle;
       }
    

提交回复
热议问题