![]() |
Bootstrap 5 has various utility classes through which we can define the full-width background of the application to make the application more interactive. We can set the background to its full width by positioning and sizing the attributes. We will explore two different scenarios where we can make full-width colored and image backgrounds in Bootstrap 5. Table of Content Full-width background with Flexbox UtilitiesWe can achieve a full-width background by using Bootstrap 5 classes. Here, we have used the bg-info class which applied the blue-colored background to the entire page. Syntax:<body class="p-3 mb-2 bg-info d-flex align-items-center justify-content-center" style="height: 100vh;">
Example: Illustration of full-width background in Bootstrap 5. HTML
Output: Full-Width Image as BackgroundFor applying a Full-Width Image Background to the application. We have applied the “d-flex” Bootstrap class to the <body> element to apply full-width background. By using the style property, we have applied the background image by providing the absolute URL of the image. The image is been applied in full width to the entire page. Syntax:<body class="bg-primary d-flex align-items-center justify-content-center" Example: Illustration of full-width Image as background using flexbox utilities. HTML
Output: Bootstrap container-fluid UtilityFor creating the full-width background using the container-fluid utility. We have used this utlitlity in the <div> element. Syntax:<div class="container-fluid"> Example: Illustration of full-width background using container-fluid utility. HTML
Output: Bootstrap row UtilityFor creating full-width background in Bootstrap 5 using the rows, we have applied the row and col classes to the <div> element and also aded to simple grey color as the background to proper demonstration. Syntax:<div class="row">
Example: Illustration of full-width background using Bootstrap row utility. HTML
Output: |
Reffered: https://www.geeksforgeeks.org
Bootstrap |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 16 |