vuetifyjs网格全高,并在溢出时滚动

问题描述 投票:1回答:1

我正在尝试使用其网格系统填写vuetifyjs应用程序的<v-content>。如何填充列以占用所有可用空间并滚动溢出到某些单元格?

enter image description here

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
})
.grid-item-blue {
  background-color: lightblue;
}

.grid-item-green {
  background-color: lightgreen;
  overflow-y: scroll;
}

.grid-item-pink {
  background-color: pink;
  height: 100px;
}
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.js"></script>

<div id="app">
  <v-app id="inspire">
    <v-app-bar app fixed dark>
      <v-toolbar-title>Toolbar</v-toolbar-title>
    </v-app-bar>
    <v-content>
      <v-container fluid fill-height pa-0>
        <v-row no-gutters class="top-row">
          <v-col cols="9" class="grid-item-blue">fill screen</v-col>
          <v-col cols="3" class="grid-item-green">independent vertical scroll
          </v-col>
        </v-row>
        <v-row no-gutters class="bottom-row">
          <v-col cols="12" class="grid-item-pink">fixed height, always on bottom</v-col>
        </v-row>
      </v-container>
    </v-content>
    <v-footer app dark>
      <span>Footer</span>
    </v-footer>
  </v-app>
</div>

这是我使用CSS网格的方式。

<div class="grid">
    <div class="grid-item-blue">fill screen</div>
    <div class="grid-item-green">independent vertical scroll</div>
    <div class="grid-item-pink">fixed height, always on bottom/</div>
</div>
.grid {
  height: calc(100vh - 64px - 36px);
  display: grid;
  gap: 10px;
  grid-template-columns: 9fr 3fr;
  grid-template-rows: 1fr 100px;
}

.grid-item-blue {
  background-color: lightblue;
  grid-column: 1 / 2;
  grid-row: 1 / 2;
}

.grid-item-green {
  background-color: lightgreen;
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  overflow-y: scroll;
}

.grid-item-pink {
  background-color: pink;
  grid-column: 1 / 3;
  grid-row: 2 / 3;
}
css flexbox vuetify.js css-grid
1个回答
0
投票
  1. 使容器成为flexbox容器。
  2. flex-grow:0;在第二个元素上。
  3. flex-grow:1;在第一个元素上。

步骤1:

<v-container fluid fill-height pa-0>

成为:

<v-container fluid pa-0 class="d-flex flex-column flex-grow-1 fill-parent-height">

最后一个类是自定义.fill-parent-height{ height:100%; }


步骤2:

<v-row no-gutters class="top-row">

成为:

<v-row no-gutters class="top-row flex-grow-1 flex-shrink-0">

第3步:

<v-row no-gutters class="bottom-row">

成为:

<v-row no-gutters class="bottom-row flex-grow-0 flex-shrink-0">

Demo

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
})
.grid-item-blue {
  background-color: lightblue;
}

.grid-item-green {
  background-color: lightgreen;
  overflow-y: scroll;
}

.grid-item-pink {
  background-color: pink;
  height: 100px;
}

.fill-parent-height {
  height: 100%;
}
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.js"></script>

<div id="app">
  <v-app id="inspire">
    <v-app-bar app fixed dark>
      <v-toolbar-title>Toolbar</v-toolbar-title>
    </v-app-bar>
    <v-content>
      <!-- <v-container fluid fill-height pa-0> -->
      <v-container fluid pa-0 class="d-flex flex-column flex-grow-1 fill-parent-height">
        <!-- <v-row no-gutters class="top-row"> -->
        <v-row no-gutters class="top-row flex-grow-1 flex-shrink-0">
          <v-col cols="9" class="grid-item-blue">fill screen</v-col>
          <v-col cols="3" class="grid-item-green">independent vertical scroll
          </v-col>
        </v-row>
        <!-- <v-row no-gutters class="bottom-row"> -->
        <v-row no-gutters class="bottom-row flex-grow-0 flex-shrink-0">
          <v-col cols="12" class="grid-item-pink">fixed height, always on bottom</v-col>
        </v-row>
      </v-container>
    </v-content>
    <v-footer app dark>
      <span>Footer</span>
    </v-footer>
  </v-app>
</div>
© www.soinside.com 2019 - 2024. All rights reserved.