Agyan
adda
Run
Reset
Copy
CSS Tutorial › CSS Grid › Responsive gallery
Back to tutorial
Code
Edit, then press Run or Ctrl+Enter
<style> .gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; } .gallery div { background: #ffd8a8; height: 90px; border-radius: 6px; display: flex; align-items: center; justify-content: center; } </style> <div class="gallery"> <div>1</div><div>2</div><div>3</div><div>4</div><div>5</div><div>6</div> </div>
Result