Bootstrap Fixed Layout
Learn how to create a fixed-width responsive layout using Bootstrap containers.
What is Bootstrap Fixed Layout?
A fixed layout is a webpage layout where the content is displayed inside a container with a defined maximum width.
In Bootstrap, the
.container class is commonly used
to create this type of layout.
Imagine a classroom with a fixed seating area.
Even if the building becomes wider, the main
classroom area stays within a controlled width.
Bootstrap's .container works in a
similar way.
Bootstrap Container
Bootstrap provides the
.container class to create a
responsive fixed-width layout.
The container automatically adjusts its maximum width according to the screen size.
<div class="container">
<h2>Bootstrap Fixed Layout</h2>
<p>
This content is inside a Bootstrap container.
</p>
</div>
The .container class gives your
content a controlled maximum width and keeps
the content centered on larger screens.
How Fixed Layout Works
A fixed layout keeps the main content inside a centered container.
Basic Fixed Layout Example
The following example creates a simple fixed layout
using Bootstrap's .container class.
<div class="container">
<h1>Welcome to CIIT Training Institute</h1>
<p>
Learn Full Stack Development with practical training.
</p>
</div>
Output:
Welcome to CIIT Training Institute
Learn Full Stack Development with practical training.
Fixed Layout with Row and Columns
We can combine .container,
.row and column classes to create
structured layouts.
<div class="container">
<div class="row">
<div class="col-md-6">
Left Content
</div>
<div class="col-md-6">
Right Content
</div>
</div>
</div>
Output:
Left Content
This section occupies 6 columns.
Right Content
This section occupies 6 columns.
Fixed Layout vs Full Width Layout
Bootstrap provides different container options.
The most common comparison is between
.container and
.container-fluid.
| Feature | .container | .container-fluid |
|---|---|---|
| Width | Controlled maximum width | Full width |
| Layout | Centered content | Edge-to-edge content |
| Common Use | Normal website content | Full-width sections |
Fixed Layout Visual Example
Browser Window
Bootstrap Container
The content remains inside the centered container area.
Real-Life Example – CIIT Training Institute
Suppose CIIT Training Institute wants to create a course page.
The page should contain:
- Course Introduction
- Course Features
- Training Details
- Contact Information
Instead of allowing the content to stretch across
the entire browser width, we can place it inside
a Bootstrap .container.
<div class="container">
<h2>CIIT Training Institute</h2>
<p>
Full Stack Development Training
</p>
<div class="row">
<div class="col-md-4">
Course Details
</div>
<div class="col-md-4">
Live Projects
</div>
<div class="col-md-4">
Interview Preparation
</div>
</div>
</div>
Output:
Course Details
Structured technical training and learning modules.
Live Projects
Practical project-based learning.
Interview Preparation
Interview preparation and practical guidance.
Advantages of Fixed Layout
- Keeps webpage content organized.
- Provides a controlled content width.
- Improves readability on large screens.
- Works well with Bootstrap rows and columns.
- Helps create clean and professional layouts.
Common Mistakes
-
Using
.containerincorrectly. - Forgetting to use rows when working with columns.
- Using too many nested containers.
-
Not understanding the difference between
.containerand.container-fluid.
Summary
In this lesson, we learned how Bootstrap's
.container can be used to create
a controlled and centered webpage layout.
We learned how a fixed layout works with rows and columns to organize webpage content.
We also compared .container with
.container-fluid and learned when to use
each layout.