I want make like this : https://getbootstrap.com/docs/4.0/components/card/#card-groups
So I want height of the box remains the same even though the description changes
My codepen like this :
https://codepen.io/positivethinking639/pen/dyyWadg?editors=1010
<v-container fluid>
<v-row dense>
<v-col
v-for="card in cards"
:key="card.title"
:cols="card.flex"
>
<v-card>
<v-img
:src="card.src"
class="white--text align-end"
gradient="to bottom, rgba(0,0,0,.1), rgba(0,0,0,.5)"
height="200px"
>
</v-img>
<v-card-text v-text="card.title"></v-card-text>
<v-card-actions>
<v-btn icon>
<v-icon>mdi-heart</v-icon>
</v-btn>
<v-btn icon>
<v-icon>mdi-bookmark</v-icon>
</v-btn>
<v-btn icon>
<v-icon>mdi-share-variant</v-icon>
</v-btn>
</v-card-actions>
</v-card>
</v-col>
</v-row>
</v-container>
I want the height card to remain the same, although the descriptions are different
How can I do it?
The above code looks fine, just you need to add d-flex class to your columns inside row to have same height like other columns
working codepen here: https://codepen.io/chansv/pen/ZEEKPaM?editors=1010
Updated: added fixes to move v-card action to bottom when flex card grows
<div id="app">
<v-app id="inspire">
<v-card
class="mx-auto"
max-width="500"
>
<v-system-bar
color="indigo darken-2"
dark
>
<v-spacer></v-spacer>
<v-icon>mdi-window-minimize</v-icon>
<v-icon>mdi-window-maximize</v-icon>
<v-icon>mdi-close</v-icon>
</v-system-bar>
<v-toolbar
color="indigo"
dark
>
<v-app-bar-nav-icon></v-app-bar-nav-icon>
<v-toolbar-title>Discover</v-toolbar-title>
<v-spacer></v-spacer>
<v-btn icon>
<v-icon>mdi-magnify</v-icon>
</v-btn>
</v-toolbar>
<v-container fluid>
<v-row dense>
<v-col
v-for="card in cards"
:key="card.title"
:cols="card.flex"
class="d-flex"
>
<v-card class="d-flex flex-column">
<v-img
:src="card.src"
class="white--text align-end"
gradient="to bottom, rgba(0,0,0,.1), rgba(0,0,0,.5)"
height="200px"
>
</v-img>
<v-card-text v-text="card.title"></v-card-text>
<v-spacer></v-spacer>
<v-card-actions>
<v-btn icon>
<v-icon>mdi-heart</v-icon>
</v-btn>
<v-btn icon>
<v-icon>mdi-bookmark</v-icon>
</v-btn>
<v-btn icon>
<v-icon>mdi-share-variant</v-icon>
</v-btn>
</v-card-actions>
</v-card>
</v-col>
</v-row>
</v-container>
</v-card>
</v-app>
</div>
new Vue({
el: '#app',
vuetify: new Vuetify(),
data: () => ({
cards: [
{ title: 'Pre-fab homes aaaaaaaaaaaaaaaaaa', src: 'https://cdn.vuetifyjs.com/images/cards/house.jpg', flex: 4 },
{ title: 'Favorite roaddddddddd', src: 'https://cdn.vuetifyjs.com/images/cards/road.jpg', flex: 4 },
{ title: 'Best airlines', src: 'https://cdn.vuetifyjs.com/images/cards/plane.jpg', flex: 4 },
],
}),
})
Vuetify supports flexbox https://vuetifyjs.com/en/styles/flex
So the only thing you've todo is to add class="d-flex"
to your v-col
<v-container fluid>
<v-row dense>
<v-col
v-for="card in cards"
:key="card.title"
:cols="card.flex"
class="d-flex"
>
<v-card class="d-flex flex-column">
<v-img
:src="card.src"
class="white--text align-end"
gradient="to bottom, rgba(0,0,0,.1), rgba(0,0,0,.5)"
height="200px"
>
</v-img>
<v-card-text v-text="card.title" class="flex-grow-1"></v-card-text>
<v-card-actions>
<v-btn icon>
<v-icon>mdi-heart</v-icon>
</v-btn>
<v-btn icon>
<v-icon>mdi-bookmark</v-icon>
</v-btn>
<v-btn icon>
<v-icon>mdi-share-variant</v-icon>
</v-btn>
</v-card-actions>
</v-card>
</v-col>
</v-row>
</v-container>
For aligning the content within the item correctly:
class="d-flex flex-column"
to v-card
class="flex-grow-1"
to your v-card-text
Override styling form v-responsive (probably this could also be solved in a nicer way)
.v-responsive {
flex: unset;
}
https://codepen.io/reijnemans/pen/WNNjmJd
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With