Bootstrap Basic Jumbotron Layout
Basic Jumbotron Layout in Bootstrap
A Jumbotron in Bootstrap is a large, flexible component used to showcase key content or call-to-actions prominently on a webpage. It’s typically used for important content such as headings, subheadings, and call-to-action buttons.
1. Basic Jumbotron Structure
The basic structure of a Jumbotron involves a container with the class jumbotron
that wraps your content.
a. Basic Jumbotron Example
HTML Code:
<div class="jumbotron">
<h1 class="display-4">Hello, world!</h1>
<p class="lead">This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.</p>
<hr class="my-4">
<p>It uses utility classes for typography and spacing to space content out within the larger container.</p>
<a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a>
</div>
<div class="jumbotron">
: The container element with thejumbotron
class, which applies the default styling.<h1 class="display-4">
: Large heading for main content or headline.<p class="lead">
: Additional text with a lead class for emphasis.<hr class="my-4">
: Horizontal rule for visual separation.<a class="btn btn-primary btn-lg" href="#" role="button">
: Button for a call-to-action.
2. Customizing Jumbotron
You can customize the appearance of the Jumbotron using utility classes and additional styling.
a. Background Color
To change the background color, use utility classes or custom CSS. For example, you can use Bootstrap’s background color utilities:
Example:
<div class="jumbotron bg-primary text-white">
<h1 class="display-4">Hello, world!</h1>
<p class="lead">This is a simple hero unit with a primary background color and white text.</p>
<hr class="my-4">
<p>It uses utility classes for typography and spacing to space content out within the larger container.</p>
<a class="btn btn-light btn-lg" href="#" role="button">Learn more</a>
</div>
bg-primary
: Applies a primary background color.text-white
: Sets the text color to white.btn-light
: Styles the button with a light color for contrast against the dark background.
b. Custom Padding and Margin
You can adjust padding and margins using Bootstrap’s spacing utilities.
Example:
<div class="jumbotron p-5 my-4">
<h1 class="display-4">Hello, world!</h1>
<p class="lead">This jumbotron has custom padding and margin applied.</p>
<hr class="my-4">
<p>It uses utility classes for typography and spacing to space content out within the larger container.</p>
<a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a>
</div>
p-5
: Adds padding inside the Jumbotron.my-4
: Adds margin on the top and bottom.
c. Responsive Jumbotron
To make the Jumbotron responsive, ensure that it scales properly on different devices. Use responsive utility classes and media queries if needed.
Example:
<div class="jumbotron jumbotron-fluid">
<div class="container">
<h1 class="display-4">Fluid jumbotron</h1>
<p class="lead">This is a modified jumbotron that occupies the entire horizontal space.</p>
</div>
</div>
jumbotron-fluid
: Makes the Jumbotron take up the full width of the viewport.<div class="container">
: Centers the content and provides responsive padding.
3. Removing Jumbotron in Bootstrap 5
In Bootstrap 5, the Jumbotron component has been removed in favor of utility classes and custom components. You can recreate similar functionality using utility classes.
Example:
<div class="bg-light p-5 rounded">
<h1 class="display-4">Hello, world!</h1>
<p class="lead">This is a simple hero unit for calling extra attention to featured content or information.</p>
<hr class="my-4">
<p>It uses utility classes for typography and spacing to space content out within the larger container.</p>
<a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a>
</div>
bg-light
: Applies a light background color.p-5
: Adds padding.rounded
: Applies rounded corners.
Summary of Basic Jumbotron Layout in Bootstrap
- Basic Structure: Use
<div class="jumbotron">
to create a standard Jumbotron. - Customization: Apply background colors, padding, margins, and text colors using Bootstrap’s utility classes.
- Responsive Design: Use
jumbotron-fluid
for full-width Jumbotrons and container classes for responsive content. - Bootstrap 5: Use utility classes to replicate Jumbotron-like functionality as the component has been removed.