css - 如何将谷歌字体连接到页面?

标签 css html fonts google-webfonts

我已经使用了 Google Fonts 中关于如何设置字体的建议。所以我做了以下操作:

1) 在页面添加了这个附件:

<link href="https://fonts.googleapis.com/css?family=Roboto:100,400,700&amp;subset=cyrillic-ext" rel="stylesheet">

2) 将 CSS 设置为 body 标签:

 html, body {
        font-family: 'Roboto', sans-serif;
        background: #f7f7f7;
    }

当我尝试为其他元素设置字体时,例如:

a {
font-family: Roboto-Light;
}

它不起作用。

enter image description here

最佳答案

a {
   font-family: 'Roboto'; /* You don't need this since you say html {font-family: 'Roboto'}*/
   font-weight: 100;
}
/*Font's family name need to be inside quotes "MyFontName"

关于css - 如何将谷歌字体连接到页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46984673/

相关文章:

javascript - 想更改 jcarousel 皮肤,但现在 div 完全丢失

jQuery:通过搜索样式 ="font-size: 70%"来匹配元素?

javascript - 使 iframe 占用垂直空间

css - 使用媒体查询将 CSS 类设置为等于 BootStrap 类

javascript - 类型错误 : Cannot set property 'innertext' of null

javascript - 如何使用 Adob​​e Illustrator Extendscript 更改当前选定文本的字体?

c# - MessageBox.Show-- 字体改变?

javascript - 移动 DIV 禁用按钮 0px 左边距

jquery - 有没有办法在 HTML5 中为 &lt;input&gt; formAction 属性设置回退?

html - 是否可以加载可变字体并使用 javascript 对其进行操作?