Roboto font in CSS

我是研究僧i 提交于 2020-08-04 01:17:05

问题


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:

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

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

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

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


回答1:


Make sure you are closing your CSS lines.

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 this regarding 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.




回答2:


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.

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.

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

* {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 */


来源:https://stackoverflow.com/questions/26730431/roboto-font-in-css

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!