📌 Objective: Learn advanced Bootstrap grid features such as offsets, ordering, equal heights, alignment, and CSS Grid integration.
🔹 1. Understanding Advanced Bootstrap Grid Features
While Bootstrap’s basic grid system provides 12 columns and responsive breakpoints, advanced techniques help create more flexible and complex layouts.
💡 Why Use Advanced Grid Features?
✔️ Helps create precise layouts without additional CSS.
✔️ Provides better alignment, spacing, and positioning.
✔️ Enhances responsiveness and flexibility.
🔹 2. Using Column Offsets (.offset-*)
Offsets add empty space before a column, pushing it to the right.
✅ Example: Centering a Column with Offsets
🔹 What happens?
- On medium (
md) screens and larger, the column takes 6/12 width and moves 3 columns to the right, centering it. - On small screens, it takes full width (
col-12).
✅ Example: Creating a Sidebar Layout with Offsets
🔹 What happens?
- The main content takes 8/12 columns.
- The sidebar takes 4/12 columns but is pushed 1 column to the right.
🔹 3. Changing Column Order (.order-*)
By default, columns are displayed in order from left to right. Use .order-* classes to change their display order.
✅ Example: Changing Column Order
🔹 What happens?
- On medium (
md) screens and larger, the order changes dynamically.- Column 3 appears first.
- Column 1 moves second.
- Column 2 moves last.
💡 Use Case: This is useful when you want different content orders for mobile vs desktop layouts.
🔹 4. Making Columns Equal Height (h-100)
Sometimes columns with different content lengths don’t align properly. Use h-100 to ensure equal heights.
✅ Example: Equal Height Columns
🔹 What happens?
- Both columns take full height (
100%) inside the row.
💡 Alternative: You can also use Flexbox (d-flex align-items-stretch) to keep columns equal.
✅ Example: Using Flexbox for Equal Heights
🔹 What happens?
- All columns take the same height automatically.
🔹 5. Aligning Columns Vertically
Use Flexbox utilities to align columns vertically inside a row.
| Class | Alignment |
|---|---|
.align-items-start |
Align items to the top |
.align-items-center |
Align items to the middle |
.align-items-end |
Align items to the bottom |
✅ Example: Centering Columns Vertically
🔹 What happens?
- The columns align in the middle of the row.
🔹 6. Using Bootstrap with CSS Grid
Bootstrap 5.3+ now supports CSS Grid layouts along with the Flexbox grid system.
💡 Why Use CSS Grid with Bootstrap?
✔️ More precise column and row placement.
✔️ Better handling of complex layouts.
✔️ More flexible alignment options.
✅ Example: Using Bootstrap with CSS Grid
🔹 What happens?
.d-gridapplies CSS Grid to the container..gap-3adds spacing between the grid rows.
📝 Lesson Recap Quiz
🎯 Test your understanding of advanced Bootstrap grid techniques.
📌 Multiple-Choice Questions (MCQs)
1️⃣ What does .offset-md-3 do?
a) Moves a column 3 spaces to the left
b) Moves a column 3 spaces to the right
c) Expands a column by 3 extra columns
d) Changes column height
✅ Correct Answer: b) Moves a column 3 spaces to the right
2️⃣ What is the purpose of .order-md-1?
a) Changes column width
b) Reorders a column position on medium screens
c) Centers a column horizontally
d) Aligns text inside a column
✅ Correct Answer: b) Reorders a column position on medium screens
3️⃣ How can you ensure equal-height columns?
a) Using .h-100
b) Using .col-auto
c) Using .order-1
d) Using .col-flex
✅ Correct Answer: a) Using .h-100
📌 True or False
4️⃣ Bootstrap’s grid system is based only on Flexbox.
✅ Answer: False (It also supports CSS Grid in Bootstrap 5.3+.)
5️⃣ The .align-items-center class aligns columns vertically in the middle.
✅ Answer: True
🎯 Practical Challenge
✅ Create a 3-column layout with:
- Centered vertical alignment (
align-items-center) - Offset second column by 2 spaces (
offset-md-2) - Reorder the third column (
order-md-1)
✅ Post your solution in the discussion forum for feedback!
🎓 Lesson Summary
✅ .offset-* moves columns right by adding empty space before them.
✅ .order-* rearranges column order dynamically.
✅ .h-100 and d-flex align-items-stretch ensure equal-height columns.
✅ Bootstrap now supports CSS Grid layouts for more flexibility.
