Discover how to build layouts that adapt perfectly without endless resizing headaches!
Why Mixing column widths in Bootsrap? - Purpose & Use Cases
Imagine you are building a webpage layout with several sections side by side. You try to set each section's width by hand using fixed pixel sizes or percentages.
When you change one section's width, you must recalculate and adjust all others manually. This is slow, error-prone, and breaks easily on different screen sizes.
Bootstrap's grid system lets you mix column widths easily by assigning column classes. It automatically handles spacing and resizing for you.
<div style="width: 200px; float: left;">Left</div><div style="width: 400px; float: left;">Right</div>
<div class='row'> <div class='col-4'>Left</div> <div class='col-8'>Right</div> </div>
You can create flexible, responsive layouts that adjust smoothly on any device without tedious math.
On a product page, you can have a smaller image column next to a larger description column that resizes nicely on phones and desktops.
Manual width setting is hard to maintain and not responsive.
Bootstrap columns let you mix widths easily with simple classes.
This creates flexible, device-friendly layouts quickly.
Practice
col-6 mean in Bootstrap's grid system?Solution
Step 1: Understand Bootstrap grid basics
Bootstrap divides a row into 12 equal parts for layout.Step 2: Interpret
The classcol-6meaningcol-6means the column uses 6 of those 12 parts, which is half the row width.Final Answer:
The column takes up half the row width (6 out of 12 parts). -> Option CQuick Check:
12 parts total, 6 parts used = half width [OK]
- Thinking col-6 means 6 pixels wide
- Confusing col-6 with fixed width units
- Assuming col-6 hides the column
Solution
Step 1: Understand responsive classes order
Bootstrap applies classes from smallest to largest screen sizes. The class without breakpoint applies to all sizes unless overridden.Step 2: Choose correct class order
To have 12 parts on small screens and 4 parts on medium and up, usecol-12for small andcol-md-4for medium screens.Final Answer:
<div class='col-12 col-md-4'></div> -> Option AQuick Check:
Small = col-12, Medium = col-md-4 [OK]
- Reversing the order of classes
- Using wrong breakpoint prefixes
- Assuming col-4 applies to small screens
<div class='row'> <div class='col-3'>A</div> <div class='col-6'>B</div> <div class='col-3'>C</div> </div>
How will the columns appear on a large screen?
Solution
Step 1: Add column widths
Columns have classes col-3, col-6, and col-3, which add up to 3+6+3=12 parts.Step 2: Understand layout on large screens
Since total is 12, all columns fit in one row side by side with widths 25%, 50%, and 25% respectively.Final Answer:
Three columns: A (25%), B (50%), C (25%) width in one row -> Option BQuick Check:
3+6+3=12 parts, fits in one row [OK]
- Thinking columns stack vertically by default
- Assuming columns overflow to next row
- Confusing col-3 with 3 pixels
<div class='row'> <div class='col-5'>X</div> <div class='col-8'>Y</div> </div>
Solution
Step 1: Calculate total column width
Adding col-5 and col-8 gives 5 + 8 = 13, which is more than 12.Step 2: Understand Bootstrap grid limits
Bootstrap rows can only hold 12 parts per row. Exceeding 12 causes the second column to wrap or break layout.Final Answer:
The total column width exceeds 12, causing layout issues. -> Option AQuick Check:
5 + 8 = 13 > 12 breaks grid [OK]
- Ignoring total width exceeding 12
- Thinking col-5 and col-8 fit in one row
- Assuming container is mandatory for row
Solution
Step 1: Define small screen behavior
On small screens, columns stack full width, so usecol-12for all columns.Step 2: Define large screen behavior
On large screens, left and right columns take 3 parts (col-lg-3), middle takes 6 parts (col-lg-6).Step 3: Combine classes correctly
Usecol-12 col-lg-3for left and right, andcol-12 col-lg-6for middle to apply small screen first, then large screen overrides.Final Answer:
<div class='col-12 col-lg-3'> for left and right, <div class='col-12 col-lg-6'> for middle -> Option DQuick Check:
Small = col-12, Large = col-lg-3 or col-lg-6 [OK]
- Reversing class order causing wrong widths
- Using col-3 for small screens instead of col-12
- Mixing breakpoint prefixes incorrectly
Ready to prove it?
Pass the test and this pattern moves unknown
