Bootstrap Jumbotron Variants
Jumbotron Variants in Bootstrap
Jumbotrons are versatile components used to highlight key content on a webpage. In Bootstrap, you can create various Jumbotron variants by applying different styles and configurations. While Jumbotron has been deprecated in Bootstrap 5, similar effects can be achieved using utility classes and custom styling. Below are common variants and how you can create them.
1. Basic Jumbotron Variant
The basic Jumbotron is the default style with a large, padded container for showcasing content.
Example:
<div class="jumbotron">
<h1 class="display-4">Welcome to My Site</h1>
<p class="lead">This is a simple hero unit to highlight key information.</p>
<hr class="my-4">
<p>Additional details about the main content or call-to-action can be included here.</p>
<a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a>
</div>
<div class="jumbotron">
: Default Jumbotron style.display-4
: Large heading.lead
: Emphasized text for the lead paragraph.
2. Fluid Jumbotron
A fluid Jumbotron spans the full width of the viewport, providing a more immersive experience.
Example:
<div class="jumbotron jumbotron-fluid">
<div class="container">
<h1 class="display-4">Fluid Jumbotron</h1>
<p class="lead">This Jumbotron takes up the entire width of the viewport.</p>
</div>
</div>
jumbotron-fluid
: Makes the Jumbotron extend the full width of its container.<div class="container">
: Centers the content and provides responsive padding.
3. Jumbotron with Background Color
You can apply background colors to the Jumbotron to enhance visual appeal or align with your brand colors.
Example:
<div class="jumbotron bg-primary text-white">
<h1 class="display-4">Welcome to Our Service</h1>
<p class="lead">We offer exceptional services tailored to your needs.</p>
<hr class="my-4">
<p>Discover more about our offerings and how we can help you achieve your goals.</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.
4. Jumbotron with Custom Padding and Margins
Adjust the padding and margins of the Jumbotron to better fit your layout.
Example:
<div class="jumbotron p-4 my-5 bg-light rounded">
<h1 class="display-4">Custom Padding Jumbotron</h1>
<p class="lead">This Jumbotron features customized padding and margins.</p>
<hr class="my-4">
<p>Use these adjustments to better fit the design of your page.</p>
<a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a>
</div>
p-4
: Adds padding inside the Jumbotron.my-5
: Adds margin on the top and bottom.bg-light
: Applies a light background color.rounded
: Applies rounded corners.
5. Jumbotron with Border
Add a border to the Jumbotron for a more defined and separated look.
Example:
<div class="jumbotron border border-primary p-4">
<h1 class="display-4">Jumbotron with Border</h1>
<p class="lead">The Jumbotron includes a primary-colored border.</p>
<hr class="my-4">
<p>Enhance the visual separation of the Jumbotron from the rest of the content.</p>
<a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a>
</div>
border border-primary
: Adds a border with the primary color.p-4
: Adds padding inside the Jumbotron.
6. Jumbotron with Responsive Design
Make the Jumbotron responsive to ensure it looks good on all devices.
Example:
<div class="jumbotron jumbotron-fluid bg-secondary text-white p-3 p-md-5">
<div class="container">
<h1 class="display-4">Responsive Jumbotron</h1>
<p class="lead">Adapts to various screen sizes using responsive padding.</p>
</div>
</div>
jumbotron-fluid
: Ensures full-width layout.p-3 p-md-5
: Responsive padding, larger on medium screens and up.
Bootstrap 5 Alternative
Since Jumbotron has been removed in Bootstrap 5, you can achieve similar designs with utility classes and custom CSS.
Example Using Bootstrap 5:
<div class="bg-primary text-white p-5 rounded">
<h1 class="display-4">Welcome to Our Site</h1>
<p class="lead">This is a simple hero unit with custom styling.</p>
<hr class="my-4">
<p>Additional information or call-to-action details.</p>
<a class="btn btn-light btn-lg" href="#" role="button">Learn more</a>
</div>
bg-primary
: Sets the background color.text-white
: Sets the text color.p-5
: Adds padding.rounded
: Applies rounded corners.
Summary of Jumbotron Variants in Bootstrap
- Basic Jumbotron: Standard large, padded container.
- Fluid Jumbotron: Full-width container.
- Background Color: Apply background and text color utilities.
- Custom Padding/Margins: Adjust spacing with utility classes.
- Border: Add borders for visual separation.
- Responsive Design: Ensure it looks good on all devices using responsive classes.
- Bootstrap 5: Use utility classes for similar effects, as Jumbotron has been removed.