0

How can I vertically center the whole content of body in Bootstrap? I've two row. I've tried with display: table-cell, but the rows stays in the same row (sorry for the words joke).

HTML

<div class="container container-table">
    <div class="row vertical-center">
        [...]
    </div>
    <div class="row vertical-center">
        [...]
    </div>
</div>

CSS

html, body, .container-table {
    height: 100%;
}

.container-table {
    display: table;
}

.vertical-center {
    display: table-cell;
    vertical-align: middle;
}

Any suggestion?

Jumpa
  • 4,319
  • 11
  • 52
  • 100

2 Answers2

1

Try wrapping both rows in a single "vertical-center" container.

<div class="container container-table">
  <div class="vertical-center">
    <div class="row">
      [...]
    </div>
    <div class="row">
      [...]
    </div>
  </div>
</div>

See fiddle

steve.n
  • 88
  • 6
0

You may try,

 .content-table{
    position: relative;
    transform: translateY(-50%);
    top: 50%;
    display: block;
   }

No need for display table-cell

LIJIN SAMUEL
  • 883
  • 4
  • 12