How to use Google fonts in React.js?

前端 未结 12 735
既然无缘
既然无缘 2020-12-02 18:06

I had built a website with React.js and webpack.

I want to use Google fonts in the webpage, so I put the link in the section.

Go

12条回答
  •  有刺的猬
    2020-12-02 18:41

    In your CSS file, such as App.css in a create-react-app, add a fontface import. For example:

    @fontface {
      font-family: 'Bungee Inline', cursive;
      src: url('https://fonts.googleapis.com/css?family=Bungee+Inline')
    }
    

    Then simply add the font to the DOM element within the same css file.

    body {
      font-family: 'Bungee Inline', cursive;
    }
    

提交回复
热议问题