Login form with background image

Bootstrap 5 Login form with background image component

Responsive Login form with background image built with Bootstrap 5. Thanks to this tutorial, you will learn how to add a background image to your login form.


Basic example

You can do it in 2 ways:

  1. Add background-image via inline CSS. Define the background height. Add .bg-image class to scale the image properly and enable responsiveness. More information can be found here.
  2. Add <img src=""> element to your div with .bg-image class. Define the image height.

You can also add a mask to your background image. If you want to use a few colors, use the gradient generator.

4:28 PM
100%
Skip
Forgot password?

Not a member? Register

        
            
                <div class="d-flex justify-content-center text-white">
                    <div class="bg-image h-100 view" style="width: 360px; min-height: 640px;">
                        <img src="https://mdbootstrap.com/img/Photos/Horizontal/Nature/6-col/img%20(122).jpg" style="min-height: 640px;" />
                        <div class="mask" style="background: linear-gradient(to bottom, rgba(0, 47, 75, 0.8) 0%, rgba(220, 66, 37, 0.8));">
                            <!--navbar-->
                            <div class="d-flex justify-content-between p-2">
                                <div>
                                    <i class="fas fa-signal"></i>
                                    <i class="far fa-bell-slash"></i>
                                    <i class="fas fa-wifi"></i>
                                </div>
                
                                <span>4:28 PM</span>
                
                                <div>
                                    <i class="fab fa-bluetooth-b"></i>
                                    <small>100%</small>
                                    <i class="fas fa-battery-full"></i>
                                </div>
                            </div>
                            <!--navbar-->
                
                            <a href="#" class="float-end font-weight-bold text-white me-4 mt-2">Skip </a>
                
                            <!-- Content -->
                            <div class="h-100 w-100 align-items-center">
                                <div class="mt-5 p-4 text-center">
                                    <div data-mdb-input-init class="form-outline form-white my-4">
                                        <input type="email" id="typeEmail" class="form-control form-control-lg" />
                                        <label class="form-label text-white" for="typeEmail">E-mail</label>
                                    </div>
                
                                    <div data-mdb-input-init class="form-outline form-white my-4">
                                        <input type="password" id="typePassword" class="form-control form-control-lg" />
                                        <label class="form-label text-white" for="typePassword">Password</label>
                                    </div>
                
                                    <a href="" class="text-white my-4">Forgot password?</a>
                
                                    <div class="d-grid my-4">
                                      <!-- Sign in button -->
                                    <button data-mdb-button-init data-mdb-ripple-init class="btn btn-lg btn-outline-white btn-block mb-3" type="submit">Sign in</button>
                
                                    <!-- Sign in button -->
                                    <button data-mdb-button-init data-mdb-ripple-init class="btn btn-lg btn-outline-white btn-block" type="submit">
                                      <i class="fab fa-facebook-f me-2"></i>Facebook</button>
                                  </div>
                
                                    <!-- Register -->
                                    <p>
                                        Not a member?
                                        <a href="" class="text-white"><strong>Register</strong></a>
                                    </p>
                                </div>
                            </div>
                            <!-- Content -->
                        </div>
                    </div>
                </div>