Didn’t find the answer you were looking for?
How do I vertically center content using Bootstrap's flexbox alignment utilities?
Asked on Dec 03, 2025
Answer
To vertically center content using Bootstrap's flexbox alignment utilities, you can use the `d-flex` class along with `align-items-center` on a parent container. This will center the content vertically within the container.
<!-- BEGIN COPY / PASTE -->
<div class="d-flex align-items-center" style="height: 200px;">
<div class="mx-auto">
Centered Content
</div>
</div>
<!-- END COPY / PASTE -->Additional Comment:
✅ Answered with Bootstrap 5 best practices.- The `d-flex` class applies the flexbox layout to the container.
- `align-items-center` vertically centers the content within the flex container.
- The `style="height: 200px;"` is used to set a height for the container, allowing vertical centering to be visible.
- `mx-auto` centers the content horizontally within the flex container.
Recommended Links:
