"Want to know the trick to make a Vuetify component stretch to fill the rest of the screen's

Imagine a scenario where there is content above and below a table on a webpage. The goal is to get the table to occupy the remaining height of the page without affecting other elements. This ensures that the content below the table is always visible at the bottom of the page.

To see a sample code demonstrating this, click link.

In attempting to implement flex-direction: column on the div element, it became apparent that this solution was not ideal, as it did not restrict the size of elements to limit the total page height. Consequently, a different approach was necessary.

A potential solution could involve utilizing a grid system with a similar layout to the one shown

Given a page with some content above and below a table. I want that table to fill the remaining height of the page, other elements should not be affected. So the content below that table should always be visible at the bottom of the page.

This is my reproduction sample code

<template>
  <v-app>
    <v-main>
      <div>
        <v-alert type="success" title="Some content above"></v-alert>
        <div class="my-2">some more content</div>
        <v-table>
          <thead>
            <tr>
              <th>Col 1</th>
            </tr>
          </thead>
          <tbody>
            <tr v-for="i in 100">
              <td>{{ i }}</td>
            </tr>
          </tbody>
        </v-table>
        <v-pagination :model-value="1" :length="10" class="my-2"></v-pagination>
      </div>
    </v-main>
  </v-app>
</template>

I tried to add flex with flex-direction: column to the div element but I think that's not correct, I don't want the elements to grow/shrink, I have to limit the page height first.

So I tried to use a grid like this

<template>
  <v-app>
    <v-main>
      <v-container class="fill-height">
        <v-row>
          <v-col>
            <v-alert type="success" title="Some content above"></v-alert>
          </v-col>
        </v-row>
        <v-row>
          <v-col>
            <div class="my-2">some more content</div>
          </v-col>
        </v-row>
        <v-row>
          <v-col>
            <v-table>
              <thead>
                <tr>
                  <th>Col 1</th>
                </tr>
              </thead>
              <tbody>
                <tr v-for="i in 100">
                  <td>{{ i }}</td>
                </tr>
              </tbody>
            </v-table>
          </v-col>
        </v-row>
        <v-row>
          <v-col>
            <v-pagination :model-value="1" :length="10" class="my-2"></v-pagination>
          </v-col>
        </v-row>
      </v-container>
    </v-main>
  </v-app>
</template>

but as you can see in the playground things are getting even worse. This is what I'm looking for

enter image description here

I think that I could solve this with CSS and vanilla JavaScript but I'm looking for a "Vuetify" solution.

There might not be a ready-made Vuetify solution available, but you don't need a lot of CSS to solve this:

.wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.v-alert {
  overflow: visible;
}
.v-table {
  overflow-y: auto;
}

Vuetify Playground example

If you want to hide the disabled full page scrollbar, simply include:

html {
  overflow: hidden;
}

This might not work in the playground due to the iframe, but it should function correctly on your local environment.

There isn't a Vuetify solution as far as I know, but the solution doesn't require that much CSS:

.wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.v-alert {
  overflow: visible;
}
.v-table {
  overflow-y: auto;
}

Vuetify Playground example

To hide the disabled full page scrollbar you can add

html {
  overflow: hidden;
}

It just doesn't work in the playground because of the iframe, but should work locally.

Answer №1

There might not be a ready-made Vuetify solution available, but you don't need a lot of CSS to solve this:

.wrapper {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.v-alert {
  overflow: visible;
}
.v-table {
  overflow-y: auto;
}

Vuetify Playground example

If you want to hide the disabled full page scrollbar, simply include:

html {
  overflow: hidden;
}

This might not work in the playground due to the iframe, but it should function correctly on your local environment.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ways to create spacing between property columns in MUI grid fashion

Is there a way to achieve space-between alignment when elements are stacked vertically in MUI Grid instead of using flex? I've come across suggestions involving giving flex:1 and height:100%, but I'm specifically interested in achieving this with ...

How come there is such a large space for clicking between my logo and the navigation bar, and what can be done to eliminate it?

* { box-sizing: border-box; padding: 0; margin: 0; } ul { list-style-type: none; } .nav-links, .logo { text-decoration: none; color: #000; } .logo { max-width: 80%; width: 20%; height: 20%; } .navbar img { width: 10%; height: auto; di ...

How can I adjust the transparency in a JavaScript popup modal window for an ASP.Net GridView?

Recently, I added an 'onclick' event to every row of an asp gridview and the popup window that appears is functioning perfectly. Now, I'm interested in adding a transparency level to the body of the popup window for a translucent effect. Can ...

Navigating post-authentication with Vue.JS and Firebase

My Vue.js application structure within the src directory looks like this: . ├── App.vue ├── assets ├── data │   ├── config.js ├── main.js ├── router.js └── views └── app ├── index.vue ...

Issue with Bootstrap 4 navigation tabs: dropdown items do not cycle through active tab panels

Whenever I utilize nav-tabs to toggle between tabpanels, it functions properly. However, there seems to be an issue when attempting to switch the active tabpanel using the links in the dropdown menu. Below is the HTML for my nav-tabs and dropdown menu, alo ...

Instructions for dividing a screen into two halves, either with a 20/80 or 30/70 split, using HTML

I've set up my HTML structure like this: <div class="row"> <div class="col"> <div class="leftside"> ...content for leftside goes here... </div> </div> <di ...

The innerHTML feature in Javascript seems to be malfunctioning

Having a simple javascript issue here. I am attempting to retrieve a date from a textbox and display it in a label for another purpose. However, I encountered some problems along the way. I can successfully alert the date retrieved from the textbox, but wh ...

Tips for displaying numbers in thousands, millions, or billions in vue.js

For example: 12000 can be shown as 12k, 1000000 as 1m, and 1430 as 1.4k. <div v-for="item in items" :key="item"> <span>{{item.num}}</span> </div> <script lang='ts'> items:any[]=[ {num:"122256879"}, ...

Discover a foolproof method for effortlessly examining an flv or mp4 file embedded within a webpage simply by

I've encountered a challenge with JavaScript. I can successfully check a flash object in a webpage when hovering over it, but I'm unsure how to achieve the same for flv or mp4 objects when either hovering over or moving away from them. Currently ...

Can an HTML DIV be resized along with its contents?

Is it possible to scale a container with animated elements inside to fit the browser window, or do you have to adjust each child element individually? ...

Issues arising when trying to generate HTML email content from a document

Looking to send an HTML email using Python, argparse, and the command line. I want to insert content from an HTML file directly into the email body rather than just attaching the file. So far, my attempts are only resulting in the HTML file being attache ...

Effect of Active or Focus on the HTML <ul> element

Check out this example of a UL tag: <ul style="list-style-type:none; padding:5px ; border:solid 1px #666666;"> <li>I am waiting </li> <li>I am waiting </li> <li>I am waiting </li> <li>I am wa ...

Having trouble getting the align-items-end property in Bootstrap 4 to function

After dedicating almost two full weeks to this project, I'm still struggling to achieve the desired outcome. I suspect that the issue may lie in the depth of the rows and columns I'm working with, but I'm open to any external perspectives or ...

Obtain the accurate PHP variable value

This question seems unfamiliar to me I have a loop in place for($i=0;$i<count($certifications);$i++){ $etc=certifications[$i]; .... <img src="/cubo/addDocument.png"/ height="24" width="24" data-toggle="modal" data-target="#addEvent"> ...

The grandchild of sibling A sends out a signal, prompting the parent to make necessary adjustments in the value, however sibling B

This template serves as the parent with 2 child components <payment :isEditing="isEditing" @action="onActionButtonClick" /> <create-details v-if="isCompanyDetailsCreating" @action="onActionButtonClick" /> ...

The error message "MediaMetadata is not defined as no-undef and cannot be used as a constructor" appeared when trying to use MediaMetadata

I have successfully implemented a playlist player using howler.js in vuejs. Now, I am looking to enhance it by integrating the MediaMetadata API. While the MediaSession API is functioning well with controls like notification bar, keyboard controls, and rem ...

What is the best way to align two blocks and a span with fixed widths horizontally using CSS?

Is it possible to have a span with a static width of 20px (like col-2) placed between two blocks with content in Bootstrap, where the blocks split the rest of the available space? Here is an example code snippet: https://jsfiddle.net/Alexik/krexqp5m/1 Co ...

Simple Steps for Dynamically Adjusting Table Cells without Disturbing Existing Data

Is there a way to make a table automatically arrange cells in rows of two, adjusting as necessary when adding or removing cells (with one cell in the last row if there is an odd number of total cells)? For example: <table> <tr> <td>o ...

Utilization of traditional techniques across various Vue components

Can you guide me on the correct usage of the method isValidEmail in compA.vue and other potential compB.vue? The following method does not seem to be effective for me: <template> <div></div> </template> <script> export de ...

Utilize AJAX to dynamically refresh the page without having to reload it, enabling the use of both POST and GET methods

In order to avoid reloading the page when refreshing, I am utilizing Ajax for this particular 3-sided content along with JavaScript. Here is the code: Content: <ul id="nav"> <li><a href="ajax_adat.php?id=8&epul=0">Data</a>< ...