Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the height of vuetify card

I am attempting to add a card with vue and vuetify that will take up the space in my container using v-flex to create a horizontal card that acts the same way vertically. I have attempted to add a height style of 100%, using fill-height, child-flex, etc but I cannot get the size of the card to fill the container. What is the correct way to adjust the height?

ref: https://vuetifyjs.com/en/components/cards

<div id="app">
  <v-app id="inspire">
    <v-toolbar color="green" dark fixed app>
      <v-toolbar-title>My Application</v-toolbar-title>
    </v-toolbar>
    <v-content >
      <v-container fluid fill-height >
        <v-layout
          justify-center
          align-center 
        >
          <v-flex text-xs-center >
              <v-card class="elevation-20" >
              <v-toolbar dark color="primary">
                <v-toolbar-title>I want this to take up the whole space with slight padding</v-toolbar-title>
                <v-spacer></v-spacer>
              </v-toolbar>
              <v-card-text>

              </v-card-text>

            </v-card>
          </v-flex>
        </v-layout>
      </v-container>
    </v-content>
    <v-footer color="green" app inset>
      <span class="white--text">&copy; 2018</span>
    </v-footer>
  </v-app>
</div>

example: https://codepen.io/anon/pen/LmVJKx

like image 471
Darwin Avatar asked Apr 20 '18 20:04

Darwin


People also ask

What is V-card Vuetify?

The v-card component is a versatile component that can be used for anything from a panel to a static image. The card component has numerous helper components to make markup as easy as possible.

Is Vuetify customizable?

Customizing. By default, Vuetify has a standard theme applied for all components. This can be easily changed. Simply pass a theme property to the Vuetify constructor.


2 Answers

I've commented on the accepted answer that:

<v-card height="100%">

gives an styling issue if you have v-card-actions (card footer).

To equalize the v-text-card component, you should create a custom (SCSS) class:

.flexcard {
  display: flex;
  flex-direction: column;
}
// Add the css below if your card has a toolbar, and if your toolbar's height increases according to the flex display.
.flexcard .v-toolbar {
  flex: 0;
}

Then, add the class to the v-card component, like this:

<v-card class="flexcard" height="100%">
  ... Your code here
</v-card>

I hope this helps if someone is facing the same issue.

Credits to Sindrepm and his CodePen

In addition to the above: The codepen does not include any card images. So in case you are using v-img components in your v-card components like this:

<v-card 
  class="flexcard"
  height="100%">
  <v-img
    height="200px" 
    :src=".\sample\image.png">
  </v-img>
...
<v-card>

you probably want to fix their maximum heights ensuring same layout on your v-card components:

<v-card 
  class="flexcard"
  height="100%">
  <v-img
    height="200px"
    max-height="200px"
    :src=".\sample\image.png">
  </v-img>
...
<v-card>
like image 28
JustDevelop Avatar answered Sep 21 '22 04:09

JustDevelop


Vuetify says for height props: Manually define the height of the card

So,in v-card element add height as follow:

<v-card height="100%">

See it in action

like image 78
Roland Avatar answered Sep 21 '22 04:09

Roland