Home › CSS Tutorial › Responsive design
Responsive design
Make a layout adapt to the screen width.
Media queries apply rules only when a condition is true. Resize the result panel or your window to see the columns stack.
Example code
<style>
.g { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.g div { background: #2e86de; color: #fff; padding: 20px; }
@media (max-width: 420px) { .g { grid-template-columns: 1fr; } }
</style>
<div class="g"><div>A</div><div>B</div><div>C</div></div>