codegurukool.com · Free coding tutorials & online compiler

Home › CSS Tutorial › CSS Grid

CSS Grid

Build two-dimensional layouts.

Grid places items in rows and columns. Use grid-template-columns, gap and grid-column to span cells.

Example code

<style>
  .g{display:grid;grid-template-columns:1fr 2fr 1fr;gap:8px}
  .g div{background:#1b998b;color:#fff;padding:16px}
  .wide{grid-column:1 / 4;background:#14213d!important}
</style>
<div class="g"><div class="wide">Header</div><div>Nav</div><div>Content</div><div>Ads</div></div>

Run this code in the online editor

← PositionTransitions and animations →