如何在React中从外部源导入样式表?

问题描述 投票:0回答:3

我的意思是来自 fontawesome 的图标或来自 google fonts 的字体。在 HTML 中,我在头部放置了这样的内容:

<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">

反应怎么样?

css reactjs
3个回答
25
投票

您可以像这样将其导入样式表中

    @import url('https://fonts.googleapis.com/css?family=Roboto');

你的体型将会变得

body {
  font-family: 'Roboto';
}

4
投票

将链接插入您的index.html

<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">

0
投票

将外部样式表添加到 css 文件第一行。

@import url('https://fonts.googleapis.com/css?family=Roboto');
* {
    margin: 0;
padding: 0;
box-sizing: border-box;
font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
© www.soinside.com 2019 - 2024. All rights reserved.