Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change font size in Vuetify based on viewport?

Tags:

I have a title:

<v-card-text style="font-size:5em">     Some Heading Here </v-card-text> 

I would like to set font size to 3em when the view is XS. Right now I duplicated it as follows:

<v-card-text hidden-xs-only style="font-size:5em">     Some Heading Here </v-card-text> <v-card-text visible-xs-only style="font-size:3em">     Some Heading Here </v-card-text> 

However I would like to avoid this duplication and solve the issue with CSS alone, but without having to write my own @media queries in the local .vue file. Is that possible?

Alternatively, I'm ok with using predefined classes instead of specifying font size directly or even different elements completely, e.g. something like <h3> when it's XS but <h2> on other viewports.

like image 723
ierdna Avatar asked Aug 29 '18 22:08

ierdna


People also ask

How do I change the font on Vuetify?

To change the default font in Vuetify, we can set the font-family CSS property in the global styles. to set the font-family value to $font-family , which is set to 'Ubuntu' . Now our Vuetify app will use Ubuntu as the default font.

How do I wrap text in Vuetify?

You can use text-wrap / text-no-wrap class. Show activity on this post. The solution for my scenario was adding word-break: break-word; to my class. The built in classnames did not do what I needed.

What font does Vuetify use?

Vuetify. js uses the Material Design spec Roboto Font. Each heading size also has a corresponding helper class to style other elements the same.

Is Vuetify responsive?

Breakpoint conditionalsThese conditional values enable responsive functionality to Vuetify features that don't support responsive by default or at all. In the next section we customize the default breakpoint values used in both JavaScript and CSS.


Video Answer


1 Answers

You can apply class based on viewport

:class="{'subheading': $vuetify.breakpoint.xs}" 
like image 73
Igor Kokotko Avatar answered Sep 19 '22 16:09

Igor Kokotko