-2

I have following HTML which works fine. But I want the div to take the height of the tab and not having to say its 200px. If I give 100% it does not work. Please ignore draggable as its 3rd party

<b-tab title="TAB">
  <div class="table-wrapper-scroll-y custom-scrollbar">
    <table class="table table-sm table-bordered table-striped table-hover">
      <draggable :list="myLoop" :options="dragOptions" :element="'tbody'" class="rows">
        <tr class="cursor-ns-resize" v-for="(row, index) in myLoop" :key="index">
          <td>
            <b-form-checkbox type="checkbox" v-model="row.checked" />
          </td>
          <td>
            <span>{{ row.label }}</span>
          </td>
        </tr>
      </draggable>
    </table>
  </div>
</b-tab>

CSS

.custom-scrollbar {
  position: relative;
  height: 200px;
  overflow: auto;
}

.table-wrapper-scroll-y {
  display: block;
}
Utsav Patel
  • 2,789
  • 1
  • 16
  • 26
user2837961
  • 1,505
  • 3
  • 27
  • 67
  • Does this answer your question? [Why doesn't height: 100% work to expand divs to the screen height?](https://stackoverflow.com/questions/7049875/why-doesnt-height-100-work-to-expand-divs-to-the-screen-height) – Rob Apr 17 '20 at 09:49

2 Answers2

0

If you give the parent (b-tab) flex then the child div will inherit the height (as long as there's no implicit height assigned to the div). You will need to set the div to have flex-grow and flex-shrink as 1 (or combine them into the single flex property - flex: 1 1).

I've added some coloured borders to the two elements for demonstrating purposes:

b-tab {
  border: 1px solid red;
  height: 200px;
  display: flex;
}

.custom-scrollbar {
  position: relative;
  overflow: auto;
  border: 1px solid blue;
  flex: 1 1;
}

.table-wrapper-scroll-y {
  display: block;
}
<b-tab title="TAB">
  <div class="table-wrapper-scroll-y custom-scrollbar">
    <table class="table table-sm table-bordered table-striped table-hover">
      <draggable :list="myLoop" :options="dragOptions" :element="'tbody'" class="rows">
        <tr class="cursor-ns-resize" v-for="(row, index) in myLoop" :key="index">
          <td>
            <b-form-checkbox type="checkbox" v-model="row.checked" />
          </td>
          <td>
            <span>{{ row.label }}</span>
          </td>
        </tr>
      </draggable>
    </table>
  </div>
</b-tab>
Richard Parnaby-King
  • 14,703
  • 11
  • 69
  • 129
-1

Maybe you need to add

*{//this effects every element
margin:0;
padding:0;
}

To your css most of the browsers add x margin and padding

ThorD125
  • 5
  • 3