简体   繁体   English

指定字体系列重量/倾斜/样式?

[英]Specifiy Font-Family Weight/Slant/Style?

So I'm using a font family for header text (Aileron to be specific), and the font family has various weights such as "Light", "Bold", "ExtraBold", and whatnot. 因此,我在标题文本中使用了字体系列(具体来说为Aileron),并且该字体系列具有各种权重,例如“ Light”,“ Bold”,“ ExtraBold”和诸如此类。 How would you declare the specific weight in CSS? 您如何在CSS中声明特定的权重?

This is my code: 这是我的代码:

h1{
    font-family:Aileron-Black;
    font-size:49pt;
    letter-spacing:-3px;
    color:white;
}

I would experiment with taking off the hyphen and putting the name of the family in quotation marks, but nothing seems to do the trick. 我会尝试删除连字符并将家庭名称加上引号,但似乎没有办法解决。

First, incloude the font via CSS in Bold and Thin: 首先,通过CSS在Bold和Thin中对字体进行模糊处理:

@font-face {
  font-family: 'Aileron';
  font-style: normal;
  font-weight: 100;
  src: local('Aileron' ), url('path/to/font/Aileron.woff') format('woff'); }

@font-face {
 font-family: 'Aileron';
 font-style: normal;
 font-weight: 800;
 src: local('Aileron-Black' ), url('path/to/font/Aileron-Black.woff') format('woff'); }

Then declare the font-weight you want to use by using the font-weight propety. 然后使用font-weight属性声明要使用的font-weight For Bold font use 800: 对于加粗字体,请使用800:

h1{ 
 font-family:'Aileron';
 font-size:49pt; 
 letter-spacing:-3px;
 color:white;
 font-weight: 800; }

Or for thin font use 100: 或对于细字体使用100:

h1{ 
 font-family:'Aileron';
 font-size:49pt; 
 letter-spacing:-3px;
 color:white;
 font-weight: 100; }

You need to use the font-weight property, it takes either a numerical value or a keyword value (such as normal or bold). 您需要使用font-weight属性,该属性可以使用数字值或关键字值(例如常规或粗体)。 You need to look up in your CSS code for the font-face declaration of the font you are using, there you will see the specific font-weight . 您需要在CSS代码中查找所用font-face的字体说明,然后在其中看到特定的font-weight

Here you can find more information. 在这里您可以找到更多信息。

Regarding your case: 关于您的情况:

h1{
    font-family: "Aileron";
    font-size:49pt;
    font-weight: bold;
    letter-spacing:-3px;
    color:white;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM