I'm trying to center a div with a parallax background image both horizontally and vertically on the page. I attempted using classes from Bootstrap 4 such as d-block
, mx-auto
, and text-center
. While it centered the div horizontally, it did not center it vertically. How can I achieve vertical centering as well?
.parallax_bg {
background: url(assets/img/corinne-kutz-211251.jpg);
background-size: cover;
height: 100%;
min-height: 100%;
overflow: auto;
}
.parallax {
background-attachment: fixed;
background-size: cover;
background-repeat: no-repeat;
}
.parallax_text > p {
font-size: 20px;
}
<section data-stellar-background-ratio="0.5" class="parallax parallax_bg text-center mx-auto d-block">
<div class="parallax_text">
<h3><em>Venenatis Nisl Porta</em></h3>
<p>Lorem vestibulum gravida ipsum non velit aliquam</p>
<a class="btn btn-primary mt-3" href="#">Read More <i class="fa fa-angle-double-right" aria-hidden="true"></i></a>
</div>
</section>