Building a Responsive Layout with Materialize CSS 12‑Column Grid
Learn how to use Materialize CSS’s responsive grid classes to create a layout that stacks, reflows, and offsets columns across small, medium, and large screens.
22 May 2026, 03:43 UTC

Desired outcome
Create a webpage layout that automatically adjusts column widths and positioning based on the viewport width using Materialize CSS’s built‑in responsive grid. The layout should:
- Stack columns vertically on screens ≤600 px (small).
- Show two equal columns on screens between 600 px and 992 px (medium).
- Display three columns of varying widths on screens ≥992 px (large).
- Optionally offset a column on large screens without writing custom CSS.
Prerequisites
Before you begin, ensure you have:
- The latest stable release of Materialize CSS (v1.0.0 or newer) – either via CDN download or local copy.
- Basic knowledge of HTML and CSS class usage.
- A modern browser with developer tools (Chrome, Firefox, Edge, or Safari) for verification.
No JavaScript initialization is required for the grid; the layout relies purely on CSS.
Focused procedure
1. Set up the HTML skeleton
Start with a minimal HTML5 document that includes the viewport meta tag and a link to the Materialize stylesheet.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Materialize Grid Demo</title>
<!-- CDN link; replace with local file if preferred -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
</head>
<body>
<div class="container">
<!-- Grid rows go here -->
</div>
</body>
</html>
The container class adds horizontal padding and centers content; it is optional but recommended for typical page layouts.
2. Define a basic row with responsive columns
Inside the container, add a row element. Each direct child of a row that uses a col class becomes a grid column.
<div class="row">
<div class="col s12 m6 l4">
<p>Column 1</p>
</div>
<div class="col s12 m6 l4">
<p>Column 2</p>
</div>
<div class="col s12 m6 l4">
<p>Column 3</p>
</div>
</div>
Explanation of the classes:
s12– on small screens (≤600 px) the column occupies all 12 grid units → full width, causing vertical stacking.m6– on medium screens (600 px – 992 px) each column takes 6 units → two columns per row.l4– on large screens (≥992 px) each column takes 4 units → three columns per row.
3. Add an offset for large screens
Suppose you want the second column to be shifted right by two large‑column widths on large screens only. Use the offset-l2 class.
<div class="row">
<div class="col s12 m6 l4">
<p>Column 1</p>
</div>
<div class="col s12 m6 l4 offset-l2">
<p>Column 2 (offset)</p>
</div>
<div class="col s12 m6 l4">
<p>Column 3</p>
</div>
</div>
The offset-l2 adds a left margin equal to two large columns, pushing the element rightward without affecting small or medium breakpoints.
4. Nest rows for complex layouts
To place a sub‑grid inside a column, nest a new row element.
<div class="row">
<div class="col s12 m6 l8">
<p>Main content</p>
</div>
<div class="col s12 m6 l4">
<!-- Sidebar with nested grid -->
<div class="row">
<div class="col s6">
<p>Sidebar item A</p>
</div>
<div class="col s6">
<p>Sidebar item B</p>
</div>
</div>
</div>
</div>
Here the sidebar splits into two equal columns on small screens (s6) while maintaining its width on larger screens.
Expected checks
After saving the file, open it in a browser and verify the behavior:
- Narrow the viewport to ≤600 px. All three main columns should stack vertically, each occupying the full width.
- Widen the viewport to between 600 px and 992 px. The columns should arrange in two‑column rows (each column 50 % width).
- Expand the viewport to ≥992 px. You should see three columns; the second column should appear shifted right by roughly two‑column widths due to the offset.
- If you added the nested sidebar example, resize to small widths and confirm the sidebar items stack vertically.
Use the browser’s device toolbar (Chrome DevTools → Toggle device toolbar) to simulate the exact breakpoint widths (600 px and 992 px) and observe the transition points.
Limitations and practical verification
While the Materialize grid is powerful, keep these constraints in mind:
- Breakpoint values are fixed in the compiled CSS (.s ≤600 px, .m ≤992 px, .l ≥992 px). To change them you must recompile the Sass source, adjusting
$grid-breakpointsand$grid-columns. - Using Materialize alongside another framework that also defines
.row,.col, or offset classes can cause collisions. Isolate each framework to separate container elements or rename classes via a build step. - The grid relies solely on CSS; if the Materialize stylesheet fails to load (e.g., network error, incorrect path), the layout will fall back to default block behavior. Verify that the
<link>tag returns a 200 status in the network tab. - Avoid overriding grid properties with
!importantin custom stylesheets, as this can break the responsive calculations.
To confirm that the grid is functioning correctly without guesswork:
- Open DevTools and select an element with a column class (e.g.,
col s12 m6 l4). - In the Computed pane, note the
widthvalue at different viewport sizes. It should match the expected percentage (100 %, 50 %, 33.33 % respectively). - Check the
margin-leftfor offset classes; it should be zero at small/medium breakpoints and equal to2 * (100% / 12)≈ 16.66 % at large breakpoints.
Recovery options
If the layout does not behave as expected:
- Confirm that the viewport meta tag is present and correctly formatted.
- Verify the Materialize CSS file loads (check the network tab for a 200 response).
- Ensure there are no typos in class names (e.g.,
col s12 m6 l4notcol s12 m6 l4with trailing spaces). - Temporarily remove any custom CSS to rule out conflicts.
- If using a build process, recompile the Sass after adjusting breakpoint variables and redeploy the generated CSS.
Following these steps will let you reliably implement a responsive layout with Materialize CSS’s grid system, adjust it for specific design needs, and troubleshoot common issues.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.