Create a responsive three column layout with Bootstrap
Description: Create three columns. On small screens they must be stacked (full width), and from the medium breakpoint they must be side by side.
Hint:
- Use
container,rowandcol-12 col-md-4.
Solution
<div class="container text-center">
<div class="row g-2">
<div class="col-12 col-md-4"><div class="p-3 border bg-light">Column 1</div></div>
<div class="col-12 col-md-4"><div class="p-3 border bg-light">Column 2</div></div>
<div class="col-12 col-md-4"><div class="p-3 border bg-light">Column 3</div></div>
</div>
</div>
Live preview
How it works
col-12gives the full width on small screens, andcol-md-4gives 4 of 12 columns from 768px.g-2adds a small gutter between the columns.
Read Grid System.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |