0

I'm trying to make this view using grid layout where only a part of the content is scrollable.
In the example below, only 'master-list' should be scrollable.

The problem is in this line: grid-template-rows: 40px calc(100vh - 40px);
I want to be able to define for the second row to just take up the available space, without overflowing.

Is there another way to do it besides using calc?

If I change it to grid-template-rows: 40px auto; then the main-view will get a scrollbar.

.main-view {
  display: grid;
  grid-template-columns: 200px 1fr 1fr;
  grid-template-rows: 40px calc(100vh - 40px);
  position: absolute;
  bottom: 0;
  top: 0;
  left: 0;
  right: 0;
}
.actions {
  background: lightgreen;
  grid-column: 2 / 4;
  grid-row: 1;
}
.filters {
  background: lightblue;
  grid-column: 1;
  grid-row: 1 / 4;
}
.master-list {
  background: lightcoral;
  grid-column: 2 / 3;
  grid-row: 2 / 4;
  overflow-y: auto;
}
<div class="main-view">
  <div class="actions">actions</div>
  <div class="filters">filters</div>
  <div class="master-list">
    <div>row</div><div>row</div><div>row</div><div>row</div><div>row</div><div>row</div>
    <div>row</div><div>row</div><div>row</div><div>row</div><div>row</div><div>row</div>
    <div>row</div><div>row</div><div>row</div><div>row</div><div>row</div><div>row</div>
    <div>row</div><div>row</div><div>row</div><div>row</div><div>row</div><div>row</div>
    <div>row</div><div>row</div><div>row</div><div>row</div><div>row</div><div>row</div>
    <div>row</div><div>row</div><div>row</div><div>row</div><div>row</div><div>row</div>
  </div>
  <div class="details">some details here</div>
</div>
lilotop
  • 527
  • 6
  • 12
  • *If I change it to grid-template-rows: 40px auto; then the main-view will get a scrollbar.* --> are you sure? I just tested and it seems fine – Temani Afif Nov 27 '19 at 10:27
  • You are right. My example here is too simple. In the actual code I have a grid inside another grid. But it was too complex to reproduce here. I'll try to put it in a codepen and add it here. – lilotop Nov 27 '19 at 10:52

0 Answers0