0

I've seen multiple examples of how to center a bootstrap card but none of them fits my needs. I'm trying to center a bootstrap card vertical and horizontal so the card is placed exactly in the center of the screen. I want to achieve this by using only bootstrap classes like mx-auto etc. I've been trying for few hours but havent come to a solution yet, this is the code im working with:

<div class="row">
<div class="col-lg-3 col-md-3 col-sm-12">
    <div class="card h-100 login-card">
        <div class="card-body">
            <h5 class="card-title">Login</h5>
            <h6 class="card-subtitle text-muted">You can login here</h6>
        </div>
        <table class="table table-borderless table-hover h-75">
            <tr>
                <td>Test</td>
            </tr>
            <tr>
                <td>Test</td>
            </tr>
            <tr>
                <td>Test</td>
            </tr>
            <tr>
                <td>Test</td>
            </tr>
        </table>
    </div>
</div>

That results in this:

enter image description here

What I'm trying to get:

enter image description here

Hope someone can help me out and find the best solution to achieve this!

Thank you!

Niels
  • 145
  • 1
  • 11

1 Answers1

1

CSS:

 .row{
    height: 100vh;
 }

HTML :

<div class="row d-flex justify-content-center align-items-center">
        <div class="col-lg-3 col-md-3 col-sm-12">
            <div class="card h-100 login-card">
                <div class="card-body">
                    <h5 class="card-title">Login</h5>
                    <h6 class="card-subtitle text-muted">You can login here</h6>
                </div>
                <table class="table table-borderless table-hover h-75">
                    <tr>
                        <td>Test</td>
                    </tr>
                    <tr>
                        <td>Test</td>
                    </tr>
                    <tr>
                        <td>Test</td>
                    </tr>
                    <tr>
                        <td>Test</td>
                    </tr>
                </table>
            </div>
        </div>
Tariqul Islam
  • 347
  • 4
  • 18