I'm currently struggling to vertically center an image within a Bootstrap 4 layout. The navbar has a fixed height of 100px, and the columns also need to have a height of 100px due to their background styling.
Despite using the align-items-center
class, I am unable to achieve vertical alignment as the image remains at the top.
.navbar-brand {
height: 100px;
padding-top: .75rem;
padding-bottom: .75rem;
font-size: 1rem;
background-color: rgba(0, 0, 0, .25);
box-shadow: inset -1px 0 0 rgba(0, 0, 0, .25);
}
.navbar {
box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .1);
background-color: #3366cc;
height: 100px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<nav class="navbar sticky-top p-0">
<div class="container-fluid h-100" style="border-bottom: 1px solid rgb(192, 192, 192); height:100px;">
<div class="row justify-content-between align-items-center h-100" style="width:100vw;">
<div class="col-2 col-xxxl-1 h-100" style="background:white;">
<img class="img-fluid" style="max-height: 100px" src="https://via.placeholder.com/350x150" alt="" />
</div>
<div class="col-2 col-xxxl-1 text-center" style="background: white;height: 100%;">
<p class="no-wrap"><a href=""> Sign out</a></p>
</div>
</div>
</div>
</nav>