CSS: Why “vertical-align: middle” does not work?

前端 未结 8 1087
无人及你
无人及你 2021-02-13 06:24

Consider the following example: (live demo here)

HTML:



        
8条回答
  •  粉色の甜心
    2021-02-13 07:00

    Just put the img tag inside a div tag the set display:table-cell vertical-align: middle to the div. Parent tag should be display:table

    Example:

    Css

    a {
     display: table;
     background: #000;
     height:200px;
    }
    div {
     display:table-cell;
     vertical-align: middle;
    }
    

    HTML

    
     

提交回复
热议问题