Center an Image vertically and horizontally using CSS

前端 未结 10 1053
遥遥无期
遥遥无期 2020-11-30 08:12

How do I vertically and horizontally center an image when I do not know the size of it? I asked this question and someone suggested using a table. This isn\'t the first time

10条回答
  •  北海茫月
    2020-11-30 08:36

    I end up doing the below. Tested with firefox, chrome, IE8 and opera. All good.

    table.NAME
    {
        background: green; //test color
        text-align: center;
        vertical-align:middle;
    }
    table.NAME tr td
    {
        width: 150px;
        height: 150px;
    }
    

    html

    
    ...
    

    提交回复
    热议问题
    dfgdfgfdgf.gif dfgdfgfdgf.gif