首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >tailwind.config.js无法访问tailwind.css中指定的字体(nuxt.js 3,nuxt.js 3)

tailwind.config.js无法访问tailwind.css中指定的字体(nuxt.js 3,nuxt.js 3)
EN

Stack Overflow用户
提问于 2022-09-11 08:43:23
回答 2查看 39关注 0票数 0

tailwind.config.js文件无法访问tailwind.css文件中指定的字体。我使用的是nuxt.js 3和tailwindcss,非常感谢您的帮助。

tailwind.css

代码语言:javascript
复制
/* /assets/css/tailwind.css */
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  body {
    background-color: #16181c;
    color: #ecf9fb;
    font-family: "Inter", Arial, sans-serif;
    margin: 1rem 5%;
  }
}

/* Inter Regular 400 */
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-regular-400.woff2");
}

/* Solway Bold 700 */
@font-face {
  font-family: "Solway";
  font-weight: 700;
  src: url("../fonts/solway-bold-700.woff2");
}

Solway字体的应用是正确的,所以导入它没有问题;将@font-face放在@layer base中不会做任何事情

tailwind.config.js

代码语言:javascript
复制
/* tailwind.config.js */
module.exports = {
  content: [
    "components/**/*.vue",
    "layouts/**/*.vue",
    "pages/**/*.vue",
    "composables/**/*.{js,ts}",
    "plugins/**/*.{js,ts}",
  ],
  theme: {
    extend: {
      fontFamily: {
        solway: ['"Solway" "Inter" Arial sans-serif'],
      },
      backgroundColor: {
        card: ["#26292f"],
      },
    },
  },
  plugins: [],
};

我是如何尝试使用新字体系列的

代码语言:javascript
复制
// /layouts/default.vue
<template>
  <header class="bg-card-0 rounded-2xl p-4 text-2xl">
    <NuxtLink to="/" class="font-solway font-bold">Second Hand</NuxtLink>
  </header>
  <slot />
</template>
EN

回答 2

Stack Overflow用户

发布于 2022-09-11 15:39:42

我的字体导入方式与您在第一个代码段中(在基本层之外)所做的相同。我认为@layer base是用于要添加到默认重置样式中的样式,而不是字体。

原木火箭文章导入字体的方式与前面提到的相同。

票数 0
EN

Stack Overflow用户

发布于 2022-09-12 13:16:11

错误发生在tailwind.config.js文件中。它是什么:

代码语言:javascript
复制
fontFamily: {
  solway: ['"Solway" "Inter" Arial sans-serif'],
},

什么是正确的:

代码语言:javascript
复制
fontFamily: {
  solway: ["Solway", "Inter", "Arial", "sans-serif"],
},
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73677949

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档