A
A
AnonymousUser2017-02-02 01:26:40
css
AnonymousUser, 2017-02-02 01:26:40

How to center a DIV vertically in Bootstrap?

Good afternoon. I want to center a DIV vertically in Bootstrap. This is my first time working with this framework.
I am attaching the code. Parent window height: 100vh and min-height: 600px;

<header>
<div class="container-fluid">
<div class="row">
<div class="col-md-5">
<h1>Доставка вкусной пиццы<br>в любую точку Москвы</h1>
<p class="expositionHeader">Бесплатная доставка по центру от XXX рублей</p>
</div>
</div>
</div>
</header>

header {
  height: 100vh;
  min-height: 600px;
}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
marrs, 2017-02-02
@AnonymousUser

There are 2 modern ways to do this dynamically
1 - flexbox

header {
  height: 100vh;
  min-height: 600px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

2 - transform:
header {
  height: 100vh;
  min-height: 600px;
  position:relative
}
.container-fluid {
  left:0;
  width:100%;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

3 - display: table and in it display:table-cell; vertical-align:middle;
the rest require you to know the height in advance

A
Artyom, 2017-02-02
@SlampD

https://css-tricks.com/centering-css-complete-guide/

A
Alexey Mylnikov, 2017-02-02
@AMBase

Maybe this option is suitable codepen.io/AMBase/pen/ggeXdB

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question