1

I am having issue with display: grid. I want header top and 33% width sidebar column and 66% for content. And I have declared grid-area. Can you help me?

.head {
  grid-area: head;
  background: tomato;
}

.side {
  grid-area: side;
  background: purple;
}

.content {
  grid-area: content;
  background: orange;
}

body {
  margin: 0;
}

* {
  box-sizing: border-box;
}

.wrapper {
  display: grid;
  grid-gap: 10px;
  grid-template-areas:
    "head head head"
    "side" "content content"
}

.box {
  padding: 20px;
  height: 100px;
}
<div class="wrapper">
  <div class="box head">
  </div>
  <div class="box side">
  </div>
  <div class="box content">
  </div>
</div>
Vadim Ovchinnikov
  • 13,327
  • 5
  • 62
  • 90
Ram kumar
  • 3,152
  • 6
  • 32
  • 49
  • The accepted answer hits the nail on the head. But also note that `"head head head" "side" "content content"` is invalid code. String values for `grid-template-areas` must all have an equal number of columns, or the rule is ignored. https://stackoverflow.com/q/45647833/3597276 – Michael Benjamin Apr 25 '18 at 15:06
  • Ok noted.. Thanks Mate – Ram kumar Apr 26 '18 at 04:48

1 Answers1

5

Just move the content next to the sidebar

.head {
  grid-area: head;
  background: tomato;
}

.side {
  grid-area: side;
  background: purple;
}

.content {
  grid-area: content;
  background: orange;
}

body {
  margin: 0;
}

* {
  box-sizing: border-box;
}

.wrapper {
  display: grid;
  grid-gap: 10px;
  grid-template-areas:
    "head head head"
    "side content content"
}

.box {
  padding: 20px;
  height: 100px;
}
<div class="wrapper">
  <div class="box head">
  </div>
  <div class="box side">
  </div>
  <div class="box content">
  </div>
</div>
Vadim Ovchinnikov
  • 13,327
  • 5
  • 62
  • 90
Horacio Coronel
  • 432
  • 2
  • 6