Reputation: 1
How to create a 4-column responsive layout?
| column left | column right |
Upvotes: 0
Views: 55
Reputation: 2247
You can use bootstrap grid as follows:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-lg-3 col-md-6 col-sm-6">col 1</div>
<div class="col-lg-3 col-md-6 col-sm-6">col 2</div>
<div class="col-lg-3 col-md-6 col-sm-6">col 3</div>
<div class="col-lg-3 col-md-6 col-sm-6">col 4</div>
</div>
Try to click on "Run code snippet" you will see the demo for small screens. Then click on "Full page" you will see it for large screens.
The bootstrap grid uses 4 screen sizes, they are:
lg
for laptops and desktops - screens equal to or greater than 1200px widemd
for small laptops - screens equal to or greater than 992px widesm
for tablets - screens equal to or greater than 768px widexs
for phones - screens less than 768px wideThe screen is divided into 12 parts, so the number after screen sizes specifies how many parts the div
should cover.
So, in the example above, the divs will cover 3 parts on large screens and 6 parts on small screens.
More information on bootstrap grid system can be found here
Upvotes: 1
Reputation: 1793
Try using bootstrap grid. Bootstrap’s grid system uses a series of containers, rows, and columns to layout and align content. It’s built with flexbox and is fully responsive. Below is an example and an in-depth look at how the grid comes together.
<div class="container">
<div class="row">
<div class="col-lg-3 col-md-6 col-sm-6"">
One of three columns
</div>
<div class="col-lg-3 col-md-6 col-sm-6"">
One of three columns
</div>
<div class="col-lg-3 col-md-6 col-sm-6"">
One of three columns
</div>
<div class="col-lg-3 col-md-6 col-sm-6"">
One of four columns
</div>
</div>
</div>
Upvotes: 0