I'm using Bootstrap 4, I'm trying to create a row in which all of the cols are vertically centred, to do this I'm using the Bootstrap 4 class align-items-center
, as per the recommendation in this SO answer.
I have the following MWE:
.yellow-row {
background-color: #f2c14e;
color: #141823;
}
.blue-col {
background-color: blue;
color: white;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="row yellow-row align-items-center">
<div class="col-lg-7 blue-col text-center">
<h1>Testing</h1>
<p>Lorem reiciendis fuga possimus quibusdam doloribus Quos eaque earum voluptatem culpa vel obcaecati, ducimus sed Necessitatibus repudiandae suscipit ipsam magni laudantium? Inventore iusto sequi excepturi voluptatibus totam cupiditate. Dignissimos
quasi</p>
</div>
<div class="col-lg-5 text-center">
<h1>Only a test</h1>
<p>Lorem quisquam dolor velit maxime officia. Quos quo nihil sint sequi iste. Sed praesentium nihil illum amet tempora. Dolore exercitationem praesentium iure accusantium quibusdam? Fuga ex inventore dignissimos aut quas</p>
<p>Lorem dolorum officiis velit deserunt facere? Dolorum provident aliquid sapiente quam perferendis Repellendus magni culpa nesciunt laborum dolorum Pariatur similique ullam quasi sit doloremque cupiditate! Autem odit mollitia libero magnam!</p>
</div>
</div>
</div>
</body>
</html>
The HTML/CSS above this produces output on larger screen widths:
The intended outcome is the blue column being the same height of the parent row (and thus the other col). I've tried adding min-height: 100%
to the .blue-col
class and I've also tried height: 100%
, neither produce the intended result. I also tried adding the Bootstrap 4 class h-100
to the blue-col
, again not the intended result.
I feel I'm lacking some fundamental understanding of how flexbox/vertical centring works in Bootstrap 4.