Bootstrap Fluid Layout
Learn how to create full-width layouts using Bootstrap's container-fluid class.
What is Bootstrap Fluid Layout?
A fluid layout is a layout where the content uses the available width of the screen.
Bootstrap provides the
.container-fluid class to create
a full-width responsive layout.
Imagine a classroom where the seating area can expand or shrink according to the available space. A fluid layout works in a similar way. It uses almost the complete available width.
Bootstrap .container-fluid
The .container-fluid class creates a
container that takes the full available width of
the viewport.
Unlike the normal .container,
the fluid container does not use a fixed maximum
width for each breakpoint.
<div class="container-fluid">
<h2>Fluid Layout</h2>
<p>
This content uses the available screen width.
</p>
</div>
Use .container-fluid when you want
your section to extend across the available
width of the screen.
Fixed Layout vs Fluid Layout
Bootstrap provides both
.container and
.container-fluid.
| Feature | .container | .container-fluid |
|---|---|---|
| Layout | Controlled width | Full available width |
| Content Area | Centered and constrained | Stretches across the viewport |
| Common Use | Normal website content | Full-width sections |
| Bootstrap Class |
.container
|
.container-fluid
|
Basic Fluid Layout Example
The following example creates a full-width section
using .container-fluid.
<div class="container-fluid">
<h1>Welcome to CIIT Training Institute</h1>
<p>
Learn Full Stack Development with practical training.
</p>
</div>
Output:
Welcome to CIIT Training Institute
This section represents a fluid layout using the available width.
Fluid Layout with Row and Columns
We can use .container-fluid together
with rows and columns to create full-width
responsive sections.
<div class="container-fluid">
<div class="row">
<div class="col-md-4">
Section 1
</div>
<div class="col-md-4">
Section 2
</div>
<div class="col-md-4">
Section 3
</div>
</div>
</div>
Output:
Section 1
Full-width layout section.
Section 2
Full-width layout section.
Section 3
Full-width layout section.
Full-Width Header Example
Fluid layouts are useful when a section needs to stretch across the available screen width.
<div class="container-fluid">
<div class="p-5 bg-dark text-white">
<h1>Bootstrap Training</h1>
<p>
Learn Bootstrap from basic to advanced concepts.
</p>
</div>
</div>
Output:
Bootstrap Training
Learn Bootstrap from basic to advanced concepts.
Creating Full-Width Sections
A fluid layout is useful for creating sections such as:
- Website banners
- Hero sections
- Full-width navigation areas
- Course sections
- Footer sections
You can use a fluid container for the outer
section and place a normal
.container inside it when you want
the content itself to remain centered.
Fluid Container with Normal Container
A common website pattern is to use a full-width outer section and a centered inner container.
<div class="container-fluid">
<div class="container">
<h2>
CIIT Training Institute
</h2>
<p>
Full Stack Development Training
</p>
</div>
</div>
Structure:
Normal Container
Content stays organized inside the full-width section.
Real-Life Example – CIIT Training Institute
Suppose CIIT Training Institute wants to create a full-width course banner.
The banner should use the complete available width of the webpage.
<div class="container-fluid">
<div class="p-5 bg-dark text-white">
<h1>
CIIT Training Institute
</h1>
<p>
Java | .NET | Python | Data Analytics
</p>
</div>
</div>
Output:
CIIT Training Institute
Java | .NET | Python | Data Analytics
Advantages of Fluid Layout
- Uses the available screen width.
- Useful for full-width website sections.
- Works well with responsive layouts.
- Useful for banners and hero sections.
- Can be combined with Bootstrap rows and columns.
Common Mistakes
-
Confusing
.containerwith.container-fluid. - Using too much content without proper spacing.
- Forgetting to use responsive columns.
- Using fluid layouts when a controlled content width would be more readable.
Summary
In this lesson, we learned that the
.container-fluid class is used to create
full-width responsive layouts.
We learned how fluid containers can work with rows and columns to create flexible webpage sections.
We also learned the difference between
.container and
.container-fluid and when to use a
full-width layout.