I am creating a layout using CSS Grids and I want to have a different space between each line.
I can create the layout perfectly by simply using margin for each element, but this view hides the simplicity of the code. Are there any network tricks that I can do for this, it grid-row-gaponly seems to take one value, which it uses for all strings.
What I'm trying to achieve looks like this:
https://jsfiddle.net/8swzgk0b/1/
.grid {
  display: grid;
  grid-template-columns: auto 25% 25%;
  grid-template-rows: auto auto auto;
  width 100%;
  margin: 20px;
  grid-column-gap: 40px;
  
}
div {
  background: #838383;
  height: 80px;
}
.wide {
  grid-column: 1 / span 3;
  margin-bottom: 5px;
}
.row-2 {
  background: green;
  margin-bottom: 10px;
}
.row-3 {
  background: blue;
  margin-bottom: 30px;
}
.row-4 {
  background: red;
  margin-bottom: 20px;
}
<div class="grid">
  <div class="wide"></div>
  <div class="row-2"></div>
  <div class="row-2"></div>
  <div class="row-2"></div>
  <div class="row-3"></div>
  <div class="row-3"></div>
  <div class="row-3"></div>
  <div class="row-4"></div>
  <div class="row-4"></div>
  <div class="row-4"></div>
</div>
 Run codeHide result
source
share