vertical-align with Bootstrap 3

后端 未结 25 3149
庸人自扰
庸人自扰 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:56

    There isn't any need for table and table-cells. It can be achieved easily using transform.

    Example: http://codepen.io/arvind/pen/QNbwyM

    Code:

    .child {
      height: 10em;
      border: 1px solid green;
      position: relative;
    }
    .child-content {
      position: absolute;
      top: 50%;
      left: 50%;
      -webkit-transform: translate(-50%, -50%);
      transform: translate(-50%, -50%);
    }
    
    
    Big
    Small

提交回复
热议问题