How to center horizontal table-cell

前端 未结 4 1326
后悔当初
后悔当初 2020-12-16 11:03

I want the Content A, Content B, and Content C columns to be horizontally centered. I have this code been trying to add

http://jsfiddle.net/hsX5q/24/

HTML:m

4条回答
  •  [愿得一人]
    2020-12-16 11:44

    Short snippet for future visitors - how to center horizontal table-cell (+ vertically)

    html, body {
      width: 100%;
      height: 100%;
    }
    
    .tab {
      display: table;
      width: 100%;
      height: 100%;
    }
    
    .cell {
      display: table-cell;
      vertical-align: middle;
      text-align: center; /* the key */
      background-color: #EEEEEE;
    }
    
    .content {
      display: inline-block; /* important !! */
      width: 100px;
      background-color: #00FF00;
    }

    Content

提交回复
热议问题