Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify different margin for different screen sizes using breakpoint in Vuetify

Tags:

vuetify.js

Question:

I have a loop displaying specified amount of cards.

The problem is with ma-5 attribute in <v-flex>. On xs screen size this margin is too big. Ho do I specify a different margin for different screen sizes?

Code:

   <v-container>       <v-layout row wrap>         <v-flex xs12 sm6 md4 ma-5 v-for="card in filteredCards" :key="card.id">           <v-card flat class="elevation-20 test">             <v-card-media :src="card.image" height="200px">             </v-card-media>             <v-card-title primary-title class="pa-4">                <div>                   <h3 class="headline mb-0">{{card.title}}</h3>                   <div style="min-height:50px;">{{card.description}}</div>                </div>             </v-card-title>           </v-card>         </v-flex>       </v-layout>    </v-container> 

Tried:


I tried adding this code below (copied from this page)

<v-flex xs12 sm6 md4 v-for="card in filteredCards" :key="card.id"    :class="{'ma-0': $breakpoint.smAndDown, 'ma-5': $breakpoint.mdAndUp}"> 

and I get these errors:

  • [Vue warn]: Property or method "$breakpoint" is not defined on the instance but referenced during render

  • [Vue warn]: Error in render: "TypeError: Cannot read property 'smAndDown' of undefined"

  • TypeError: Cannot read property 'smAndDown' of undefined


like image 480
Un1 Avatar asked Jan 07 '18 12:01

Un1


People also ask

How do I change my height on Vuetify?

To set the height of Vuetify card with Vue. js, we can set the height prop of the v-card component. to set the height prop of the v-card component to 100% to set the height of the card to 100%.

What is V spacer in Vuetify?

The v-spacer component is useful when you want to fill available space or make space between two components.


1 Answers

$vuetify.breakpoint.smAndDown

Notice $vuetify

In your case:

<v-flex      v-for="card in filteredCards"     :key="card.id"     :class="{'ma-0': $vuetify.breakpoint.smAndDown, 'ma-5': $vuetify.breakpoint.mdAndUp}"     xs12 sm6 md4   > 

Check docs (Breakpoint object)

like image 65
Traxo Avatar answered Sep 16 '22 12:09

Traxo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!