发布于 2019-06-17 13:25:40
发布于 2020-03-04 14:37:42
我的解决方案在variables.scss文件中全局更改字体大小:
这是假设您使用的是Vuetify 2和@vue/ 3.11或更高版本。
步骤1:
在src/scss/中创建_emptyfile.sass和_font-size-overrides.scss。
在_emptyfile.sass中,您可以添加以下注释:
// empty file to workaround this issue: https://github.com/vuetifyjs/vuetify/issues/7795步骤2:
在_font-size-overrides.scss文件中:
/**
* define font-sizes with css custom properties.
* you can change the values of these properties in a media query
*/
:root {
--headings-size-h1: 28px;
--headings-size-h2: 22px;
@media #{map-get($display-breakpoints, 'lg-and-up')} {
--headings-size-h1: 32px;
--headings-size-h2: 26px;
}
}步骤3:
在variables.scss文件中(在该文件中,您重写了Vuetify变量):
/**
* Override Vuetify variables as you normally would
* NOTE: remember to provide a fallback for browsers that don't support Custom Properties
* In my case, I've used the mobile font-sizes as a fallback
*/
$headings: (
'h1': (
'size': var(--headings-size-h1, 28px),
),
'h2': (
'size': var(--headings-size-h2, 22px),
)
);步骤3:
在vue.config.js文件中:
module.exports = {
css: {
loaderOptions: {
sass: {
prependData: `@import "@/scss/_emptyfile.sass"` // empty file to workaround this issue: https://github.com/vuetifyjs/vuetify/issues/7795
},
scss: {
prependData: `@import "@/scss/variables.scss"; @import "@/scss/_font-size-overrides.scss";`,
}
}
},
};发布于 2021-10-18 12:35:47
variables.scss文件中的全局字体大小
html {
font-size: 90%;
@media only screen and (min-width: 600px) {
font-size: 94%;
}
@media only screen and (min-width: 1000px) {
font-size: 98%;
}
@media only screen and (min-width: 1200px) {
font-size: 100%;
}
}https://stackoverflow.com/questions/56603008
复制相似问题