Vertical align all(!) elements in TD?

前端 未结 11 1088
鱼传尺愫
鱼传尺愫 2021-01-31 14:28

I have a simple table with 1 TD with vertical-align:middle;. This TD contains an Image :



        
11条回答
  •  北荒
    北荒 (楼主)
    2021-01-31 14:42

    Here's a JS fiddle solution

    fiddle

    Here's the css

      table
    {
      border:solid 1px red;
      width:300px;
    }
    
    td
    {
      height:100px;
      vertical-align:middle;
      width:100%;
      border:solid 1px green;
    }
    img
    {
      display: inline;
    height: 43px;
    width: 43px;
      position: relative !important;
    float: left;
    }
    
    span
    {
      height: auto !important;
    width: 80%;
    float: right;
    position: relative;
    vertical-align: middle !important;
    text-align: left;
    }
    

提交回复
热议问题