vertical-align with Bootstrap 3

后端 未结 25 2470
庸人自扰
庸人自扰 2020-11-21 05:34

I\'m using Twitter Bootstrap 3, and I have problems when I want to align vertically two div, for example — JSFiddle link:

25条回答
  •  野性不改
    2020-11-21 05:46

    OK, accidentally I've mixed a few solutions, and it finally works now for my layout where I tried to make a 3x3 table with Bootstrap columns on the smallest resolution.

    /* Required styles */
    
    #grid a {
      display: table;
    }
    
    #grid a div {
      display: table-cell;
      vertical-align: middle;
      float: none;
    }
    
    
    /* Additional styles for demo: */
    
    body {
      padding: 20px;
    }
    
    a {
      height: 40px;
      border: 1px solid #444;
    }
    
    a > div {
      width: 100%;
      text-align: center;
    }
    
    
    

提交回复
热议问题