DEV Community 👩‍💻👨‍💻


Posted on • Originally published at

How to Center Div in Bootstrap 5

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="" 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>

Enter fullscreen mode Exit fullscreen mode

bootstrap 5 div center

Top comments (0)

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.