Search code examples
htmlcsscss-grid

Is it possible, with CSS-Grid's `gap` property, to choose for there to be gaps between some column or rows - and not between others?


Is it possible, with gap, to choose for there to be gaps between some columns or rows and not for others?


Solution

  • Not specific columns or rows. The gap property can only change columns, rows or both. You may instead manipulate elements inside your grid-cells to have a specific margin such as

    margin-left: 20px;
    

    Another method is to create a whole empty row/column although this is discouraged.

    grid-template-columns: 1fr 20px 1fr; /* 20px gap between the two columns */