CSS CSS中的Roboto字体

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26730431/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 02:43:32  来源:igfitidea点击:

Roboto font in CSS

cssfonts

提问by Jaros?aw Rewers

I would like to use "Roboto" font in prestashop. I've received design in .psd files and graphic designer used fonts "Roboto Medium" and "Roboto Regular". Do i understand correctly, that when i want to use Roboto Normal I can apply:

我想在 prestashop 中使用“Roboto”字体。我收到了 .psd 文件中的设计,图形设计师使用了字体“Roboto Medium”和“Roboto Regular”。我是否理解正确,当我想使用 Roboto Normal 时,我可以申请:

font- family: "Roboto"
font-weight: 400

and when i want to use Roboto Medium I should apply:

当我想使用 Roboto Medium 我应该申请:

font- family: "Roboto"
font-weight: 500

In other words, are weights 400 and 500 respectively equal to Roboto Normal and Roboto Medium?

换句话说,权重 400 和 500 是否分别等于 Roboto Normal 和 Roboto Medium?

回答by EternalHour

Make sure you are closing your CSS lines.

确保关闭 CSS 行。

font-family: "Roboto";
font-weight: 400;

Yes, your weights are correct,

是的,你的体重是正确的,

font-weight: 400; //normal
font-weight: 500; //medium
font-weight: 700; //bold

Please read thisregarding font-weight, it's not always available depending on the font. But, according to Google, you should be able to use those weights without a problem.

请阅读有关font-weight,它取决于字体并不总是可用的。但是,根据Google 的说法,您应该能够毫无问题地使用这些权重。

回答by Gary Richter

I was a little confused by this initially as well.

我最初也对此感到有些困惑。

I had a client request and per their style guide I needed to set fonts accordingly for "Roboto", "Roboto Medium", "Roboto Light", etc.

我有一个客户请求,根据他们的风格指南,我需要为“Roboto”、“Roboto Medium”、“Roboto Light”等设置相应的字体。

Looking at Google's font site ( https://fonts.google.com/specimen/Roboto) They show the "Roboto" font, then examples of each variation of it "Medium", "Light", etc.

查看 Google 的字体站点 ( https://fonts.google.com/specimen/Roboto) 他们展示了“Roboto”字体,然后是“中”、“轻”等每个变体的示例。

But it's not obvious that this involves two settings in CSS. My initial thought was that you set it like this:

但这并不明显,这涉及 CSS 中的两个设置。我最初的想法是你这样设置:

* {font-family: 'Roboto Light', 'Roboto Medium', 'Roboto', etc}

But after experimenting and a little research, it involves two settings, one to specify the core "family" then the variation is the "weight" like this:

但是经过实验和一点研究,它涉及两个设置,一个指定核心“家庭”,然后变化是“权重”,如下所示:

.Roboto{font-family:'Roboto';font-weight:400;} /* 400 is industry standard for normal */

.RobotoLight{font-familiy:'Roboto';font-weight:300;} /* 300 is industry standard for normal */

.RobotoMedium{font-family:'Roboto';font-weight:500;} /* 500 is industry standard for normal */