I'm having difficulty with vertically aligning my container. I've attempted to follow the steps outlined in this article: Vertical Align Center in Bootstrap 4
This is part of a school project, and it's my first time working with HTML/CSS, so I'm not very skilled at it. The only solution that somewhat worked was setting the container to have a height of vh-100
and using my-auto
on the rows. I grouped the rows within a container to keep them together. However, setting the container to be 100% of the viewport height caused overflow issues, resulting in vertical scrolling.
The other suggestions mentioned in the article did not produce the desired effect for me. I'm unsure of where I may be going wrong.
I made a few custom CSS changes to adjust the card height to 400px and modify some colors. Without these modifications, the layout does not work as expected either.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dbb9b4b4afa8afa9baab9beff5edf5ea">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-zCbKRCUGaJDkqS1kPbPd7TveP5iyJE0EjAuZQTgFLD2ylzuqKfdKlfG/eSrtxUkn" crossorigin="anonymous">
<div class="container d-flex flex-column container-fluid">
<div class="wrapper">
<div class="row">
<div class="offset-2 col-sm-4">
<span>Title</span>
</div>
</div>
<div class="row">
<div class="offset-2 col-sm-4">
<div class="card bg-black">
<div class="card-body text-center flex-column d-flex">
<img class="mx-auto" src="https://via.placeholder.com/100"/>
<h2 class="card-title text-center text-on-dark font-weight-bold">Mentor</h2>
<p class="card-text text-left text-on-dark px-5">Yada yada yada</p>
<button type="button" class="btn btn-gold btn-lg rounded-pill align-self-center mt-auto mb-3" style="width: 230px">GRADE</button>
</div>
</div>
</div>
<div class="col-sm-4">
<div class="card bg-primary">
<div class="card-body text-center flex-column d-flex">
<img class="mx-auto" src="https://via.placeholder.com/100"/>
<h2 class="card-title text-center text-white font-weight-bold">Student</h2>
<p class="card-text text-left text-white px-5">Blah blah blah</p>
<button type="button" class="btn btn-white btn-lg rounded-pill align-self-center mt-auto mb-3" style="width: 230px">STUDY</button>
</div>
</div>
</div>
</div>
</div>
</div>