Reputation: 6816
I'm trying to fill out the <v-content>
of a vuetifyjs app using its grid system. How can fill out columns to take up all available space and scroll overflow to certain cells?
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>
This is how I have it working using css grid.
<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;
}
Upvotes: 3
Views: 4263
Reputation:
flex-grow:0;
On the second element.flex-grow:1;
On the first element.Step 1:
<v-container fluid fill-height pa-0>
Becomes:
<v-container fluid pa-0 class="d-flex flex-column flex-grow-1 fill-parent-height">
The last class, Is a simple custom class .fill-parent-height{ height:100%; }
Step 2:
<v-row no-gutters class="top-row">
Becomes:
<v-row no-gutters class="top-row flex-grow-1 flex-shrink-1">
Step 3:
<v-row no-gutters class="bottom-row">
Becomes:
<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;
}
.grid-item-green>p{
height:9000px;
border:10px solid;
margin:20px;
}
.fill-parent-height {
height: 100%;
}
.top-row{
min-height: 0;
}
<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 style="height:100vh">
<!-- <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-1">
<v-col cols="9" class="grid-item-blue fill-parent-height">
fill screen
</v-col>
<v-col cols="3" class="grid-item-green fill-parent-height">
independent vertical scroll
<p>long element</p>
</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>
Edit:
For the green Element to be scrollable we need to propagate the height down from the html or use viewport units on an arbitrary container element, I picked <v-content style="height:100vh">
I update the demo above.
Upvotes: 5