简体   繁体   English

如何在 tailwind css 中将字体系列更改为 Lato?

[英]How to change font-family to Lato in tailwind css?

How to change font-family to Lato in tailwind css in my navbar?如何在我的导航栏中将字体系列更改为顺风 css 中的 Lato? i tried to do something like font-family-lato but it didint work out can anyone can tell how to change it in my navbar text?我尝试做一些类似 font-family-lato 的事情,但它没有成功任何人都可以告诉我如何在我的导航栏文本中更改它吗?

<nav class="bg--800 text-white py-4 flex items-center justify-between font-lato">
                <a href="#" class="font-bold text-xl">Logo</a>
                <ul class="flex">
                    <li class="mr-6">
                        <a href="#" class="text-base hover:text-orange-500">Home</a>
                    </li>
                    <li class="mr-6">
                        <a href="#" class="text-base hover:text-orange-500">About</a>
                    </li>
                    <li class="mr-6">
                        <a href="#" class="text-base hover:text-orange-500">Contact</a>
                    </li>
                </ul>
            </nav>

in tailwind configuration file:在顺风配置文件中:

fontFamily: {
      'Lato': ['Lato', 'sans-serif'],
    },

Don't forget to import the font in your CSS file.不要忘记在 CSS 文件中导入字体。

Change Default font:更改默认字体:

@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  html {
    font-family: Proxima Nova, system-ui, sans-serif;
  }
}

Change Font with class使用 class 更改字体

module.exports = {
  theme: {
    fontFamily: {
      'sans': ['ui-sans-serif', 'system-ui', ...],
      'serif': ['ui-serif', 'Georgia', ...],
      'mono': ['ui-monospace', 'SFMono-Regular', ...],
      'display': ['Oswald', ...],
      'body': ['"Open Sans"', ...],
    }
  }
}

<div class="font-body"> Open Sans font </div>

If you want to change the font inside the Html file do如果要更改 Html 文件中的字体,请执行

<h1 class = "font-['Lato']">Hello</h1>
<h1 class = "font-['Arvo']">Hello2</h1>

Refer Here for more information about setting and using font-family in Tailwind有关在 Tailwind 中设置和使用字体系列的更多信息,请参阅此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM