Search code examples
cssgridoffsetcss-grid

Trying to build this CSS grid


I successfully created the grid, with the CSS display:grid; property, like this:

1 2
3 4
5 6

But I'm struggling with creating the offset, like this:

http://share.activ.is/Yjy8xZ

Anyone?


Solution

  • Here is the code:

    .grid-container {
      display: grid;
      grid-template-columns: auto auto;
      padding: 10px;
    }
    
    .grid-item:nth-child(2n) {
      border: 2px dashed red;
      margin-top: 10px;
    }
    <div class="grid-container">
      <div class="grid-item">1</div>
      <div class="grid-item">2</div>
      <div class="grid-item">3</div>
      <div class="grid-item">4</div>
      <div class="grid-item">5</div>
      <div class="grid-item">6</div>
    </div>