Offset columns help you move content to the right without adding empty columns. It creates space on the left side of a column.
Offset columns in Bootsrap
Introduction
Syntax
Bootsrap
<div class="col-md-offset-3 col-md-6">Content</div>
Use col-{breakpoint}-offset-{number} to move a column right by that many grid columns.
Replace {breakpoint} with screen size like sm, md, lg.
Examples
Bootsrap
<div class="row"> <div class="col-md-offset-2 col-md-8">Centered content</div> </div>
Bootsrap
<div class="row"> <div class="col-sm-offset-1 col-sm-10">Content with small offset</div> </div>
Bootsrap
<div class="row"> <div class="col-lg-offset-3 col-lg-6">Large screen offset</div> </div>
Sample Program
This example shows a blue box that is pushed to the right by 3 columns on medium screens, making it centered in the row.
Bootsrap
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Bootstrap Offset Columns Example</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/css/bootstrap.min.css" rel="stylesheet"> <style> .box { background-color: #5bc0de; color: white; padding: 1rem; text-align: center; border-radius: 0.25rem; } </style> </head> <body> <div class="container"> <h2>Offset Columns Demo</h2> <div class="row"> <div class="col-md-offset-3 col-md-6 box"> This column is offset by 3 columns on medium screens. </div> </div> </div> </body> </html>
Important Notes
Offset classes only work inside a .row container.
Bootstrap 3 uses col-md-offset-* syntax; Bootstrap 4 and 5 use offset-md-*.
Offsetting helps create balanced layouts without empty columns.
Summary
Offset columns move content right by empty grid columns.
Use col-{breakpoint}-offset-{number} in Bootstrap 3.
Offsets help center or space columns easily.
Practice
1. What does the
offset class in Bootstrap do to a column?easy
Solution
Step 1: Understand the purpose of offset classes
Offset classes in Bootstrap add empty space to the left of a column, effectively moving it right.Step 2: Recognize the effect on layout
This shifting right is done by skipping grid columns, creating space before the column starts.Final Answer:
It moves the column to the right by a specified number of grid spaces. -> Option DQuick Check:
Offset = move right [OK]
Hint: Offset means shifting column right by empty spaces [OK]
Common Mistakes:
- Thinking offset changes color
- Assuming offset makes column full width
- Confusing offset with hiding columns
2. Which is the correct Bootstrap 3 class to offset a column by 3 grid spaces on medium screens?
easy
Solution
Step 1: Recall Bootstrap 3 offset syntax
Bootstrap 3 usescol-{breakpoint}-offset-{number}for offsets.Step 2: Match the correct order and spelling
The correct format iscol-md-offset-3for medium screens offset by 3.Final Answer:
col-md-offset-3 -> Option BQuick Check:
col-md-offset-3 syntax [OK]
Hint: Remember: col-{breakpoint}-offset-{number} in Bootstrap 3 [OK]
Common Mistakes:
- Swapping order of words in class
- Using offset before breakpoint
- Missing 'col-' prefix
3. Given this Bootstrap 3 code:
What will be the visual result in a medium screen?
<div class="row"> <div class="col-md-4 col-md-offset-4">Centered content</div> </div>
What will be the visual result in a medium screen?
medium
Solution
Step 1: Analyze the column width and offset
The column is 4 grid spaces wide and offset by 4 grid spaces on medium screens.Step 2: Calculate total grid usage
Bootstrap grid has 12 columns. Offset 4 + width 4 = 8 columns used, leaving 4 columns empty on the right.Step 3: Understand centering effect
Offset 4 pushes the column right, centering it horizontally because 4 (offset) + 4 (width) + 4 (remaining) = 12.Final Answer:
The content will be centered horizontally in the row. -> Option CQuick Check:
Offset 4 + width 4 centers content [OK]
Hint: Offset + width = 12 centers content in Bootstrap grid [OK]
Common Mistakes:
- Ignoring offset effect on position
- Assuming offset adds width
- Thinking offset hides content
4. Identify the error in this Bootstrap 3 code snippet:
<div class="row"> <div class="col-md-6 offset-md-3">Content</div> </div>
medium
Solution
Step 1: Check Bootstrap 3 offset class naming
Bootstrap 3 requires offset classes to be namedcol-{breakpoint}-offset-{number}.Step 2: Compare given class with correct syntax
The code usesoffset-md-3, which is incorrect for Bootstrap 3.Final Answer:
The offset class is incorrectly named; it should becol-md-offset-3. -> Option AQuick Check:
Bootstrap 3 offset = col-md-offset-3 [OK]
Hint: Use full offset class: col-{breakpoint}-offset-{number} [OK]
Common Mistakes:
- Using Bootstrap 4+ offset syntax in Bootstrap 3
- Missing 'col-' prefix in offset class
- Assuming offset number limits
5. You want to create a layout with two columns on medium screens: the first column is 3 grid spaces wide and the second column is 4 grid spaces wide, but the second column should start after skipping 2 grid spaces from the first column. Which Bootstrap 3 classes achieve this?
hard
Solution
Step 1: Assign width to first column
The first column should be 3 grid spaces wide, so usecol-md-3.Step 2: Offset second column by 2 grid spaces
The second column is 4 wide and should start after 2 empty spaces, so usecol-md-4 col-md-offset-2.Step 3: Verify total grid usage
3 (first) + 2 (offset) + 4 (second) = 9 grid spaces used, valid within 12.Final Answer:
<div class="col-md-3">...</div> <div class="col-md-4 col-md-offset-2">...</div> -> Option AQuick Check:
Offset second column by 2 with col-md-offset-2 [OK]
Hint: Offset second column by 2 with col-md-offset-2 [OK]
Common Mistakes:
- Offsetting first column instead of second
- Using wrong offset class syntax
- Adding widths that exceed 12 columns
Recommended
Ready to prove it?
Pass the test and this pattern moves unknown
10 questions ~5 mineasy hard
