How to Center Div in Bootstrap 5

06/22 By frontendshape

In this short tutorial we will see how to center div horizontally and vertically in bootstrap 5 .first you need to setup bootstrap 5 project or you can read below article.

How to install & setup bootstrap 5

1. Bootstrap 5 using .d-flex .align-items-center and .justify-content-center class to centered any div element.

<!DOCTYPE html>
<html lang="en">

        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Bootstrap 5 Div Center</title>
        <link href="[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">


        <div class="d-flex align-items-center justify-content-center vh-100">
            <div class="shadow p-4">
                <h5>Bootstrap 5 Div Center</h5>

bootstrap 5 div center

bootstrap 5 div center

Enter Your Search Query