css字体加粗

At the dawn of the web you only had a handful of fonts you could choose from.

在网络诞生之初,您只有少数几种字体可以选择。

Thankfully today you can load any kind of font on your pages.

值得庆幸的是,今天您可以在页面上加载任何字体。

CSS has gained many nice capabilities over the years in regards to fonts.

多年来,CSS在字体方面获得了许多不错的功能。

The font property is the shorthand for a number of properties:

font属性是许多属性的简写:

  • font-family

    font-family

  • font-weight

    font-weight

  • font-stretch

    font-stretch

  • font-style

    font-style

  • font-size

    font-size

Let’s see each one of them and then we’ll cover font.

让我们看看它们中的每一个,然后我们将介绍font

Then we’ll talk about how to load custom fonts, using @import or @font-face, or by loading a font stylesheet.

然后,我们将讨论如何使用@import@font-face或通过加载字体样式表来加载自定义字体。

font-family (font-family)

Sets the font family that the element will use.

设置元素将使用的字体系列

Why “family”? Because what we know as a font is actually composed of several sub-fonts. which provide all the style (bold, italic, light..) we need.

为什么是“家庭”? 因为我们所知道的字体实际上是由几个子字体组成的。 提供我们需要的所有样式(粗体,斜体,浅色..)。

Here’s an example from my Mac’s Font Book app - the Fira Code font family hosts several dedicated fonts underneath:

这是我Mac的Font Book应用程序中的一个示例-Fira Code字体家族在下面托管了几种专用字体:

This property lets you select a specific font, for example:

此属性使您可以选择特定的字体,例如:

body {font-family: Helvetica;
}

You can set multiple values, so the second option will be used if the first cannot be used for some reason (if it’s not found on the machine, or the network connection to download the font failed, for example):

您可以设置多个值,因此,如果由于某种原因无法使用第一个选项(例如,在计算机上找不到该选项,或者下载字体的网络连接失败),则将使用第二个选项:

body {font-family: Helvetica, Arial;
}

I used some specific fonts up to now, ones we call Web Safe Fonts, as they are pre-installed on different operating systems.

到目前为止,我使用了一些特定的字体,我们将其称为Web安全字体 ,因为它们已预先安装在不同的操作系统上。

We divide them in Serif, Sans-Serif, and Monospace fonts. Here’s a list of some of the most popular ones:

我们将它们分为Serif,Sans-Serif和Monospace字体。 以下是一些最受欢迎的列表:

Serif - Georgia - Palatino - Times New Roman - Times

Serif-乔治亚州-Palatino-时代New Roman-时代

Sans-Serif - Arial - Helvetica - Verdana - Geneva - Tahoma - Lucida Grande - Impact - Trebuchet MS - Arial Black

Sans-Serif -Arial-Helvetica-Verdana-日内瓦-Tahoma-Lucida Grande-冲击-Trebuchet MS-Arial Black

Monospace - Courier New - Courier - Lucida Console - Monaco

Monospace-快递-快递-Lucida Console-摩纳哥

You can use all of those as font-family properties, but they are not guaranteed to be there for every system. Others exist, too, with a varying level of support.

您可以将所有这些都用作font-family属性,但不能保证它们在每个系统中都存在。 其他人也存在不同程度的支持。

You can also use generic names:

您也可以使用通用名称:

  • sans-serif a font without ligatures

    sans-serif没有连字的字体

  • serif a font with ligatures

    serif字体带连字

  • monospace a font especially good for code

    monospace字体,特别适合代码

  • cursive used to simulate handwritten pieces

    cursive用于模拟手写作品

  • fantasy the name says it all

    fantasy这个名字说明了一切

Those are typically used at the end of a font-family definition, to provide a fallback value in case nothing else can be applied:

这些通常用于font-family定义的末尾,以提供备用值,以防万一无法应用其他任何方法:

body {font-family: Helvetica, Arial, sans-serif;
}

font-weight (font-weight)

This property sets the width of a font. You can use those predefined values:

此属性设置字体的宽度。 您可以使用这些预定义的值:

  • normal
    正常
  • bold
    胆大
  • bolder (relative to the parent element)
    粗体(相对于父元素)
  • lighter (relative to the parent element)
    更轻(相对于父元素)

Or using the numeric keywords

或使用数字关键字

  • 100
    100
  • 200
    200
  • 300
    300
  • 400, mapped to normal

    400,映射为normal

  • 500
    500
  • 600
    600
  • 700 mapped to bold

    700映射为bold

  • 800
    800
  • 900
    900

where 100 is the lightest font, and 900 is the boldest.

其中100是最浅的字体,而900是最粗体。

Some of those numeric values might not map to a font, because that must be provided in the font family. When one is missing, CSS makes that number be at least as bold as the preceding one, so you might have numbers that point to the same font.

其中一些数字值可能无法映射到字体,因为必须在字体系列中提供该值。 如果缺少一个,CSS将使该数字至少与前一个数字一样大胆,因此您可能会有指向相同字体的数字。

font-stretch (font-stretch)

Allows to choose a narrow or wide face of the font, if available.

允许选择字体的窄字体或宽字体(如果有)。

This is important: the font must be equipped with different faces.

这很重要:字体必须配备不同的字体。

Values allowed are, from narrower to wider:

允许的值从窄到宽:

  • ultra-condensed

    ultra-condensed

  • extra-condensed

    extra-condensed

  • condensed

    condensed

  • semi-condensed

    semi-condensed

  • normal

    normal

  • semi-expanded

    semi-expanded

  • expanded

    expanded

  • extra-expanded

    extra-expanded

  • ultra-expanded

    ultra-expanded

font-style (font-style)

Allows you to apply an italic style to a font:

允许您将斜体样式应用于字体:

p {font-style: italic;
}

This property also allows the values oblique and normal. There is very little, if any, difference between using italic and oblique. The first is easier to me, as HTML already offers an i element which means italic.

此属性还允许值obliquenormal 。 很少有,如果有的话,使用之间的差异italicoblique 。 第一个对我来说比较容易,因为HTML已经提供了一个i元素,它表示斜体。

font-size (font-size)

This property is used to determine the size of fonts.

此属性用于确定字体的大小。

You can pass 2 kinds of values:

您可以传递2种值:

  1. a length value, like px, em, rem etc, or a percentage

    长度值,例如pxemrem等,或百分比

  2. a predefined value keyword
    预定义的值关键字

In the second case, the values you can use are:

在第二种情况下,可以使用的值为:

  • xx-small
    xx小
  • x-small
  • small
  • medium
  • large
  • x-large
    x大
  • xx-large
    xx大
  • smaller (relative to the parent element)
    较小(相对于父元素)
  • larger (relative to the parent element)
    更大(相对于父元素)

Usage:

用法:

p {font-size: 20px;
}li {font-size: medium;
}

font-variant (font-variant)

This property was originally used to change the text to small caps, and it had just 3 valid values:

此属性最初用于将文本更改为小写,并且只有3个有效值:

  • normal

    normal

  • inherit

    inherit

  • small-caps

    small-caps

Small caps means the text is rendered in “smaller caps” beside its uppercase letters.

小写大写表示文本以大写字母旁边的“小写大写”呈现。

font (font)

The font property lets you apply different font properties in a single one, reducing the clutter.

font属性使您可以在一个字体中应用不同的字体属性,从而减少混乱。

We must at least set 2 properties, font-size and font-family, the others are optional:

我们必须至少设置2个属性, font-sizefont-family ,其他属性是可选的:

body {font: 20px Helvetica;
}

If we add other properties, they need to be put in the correct order.

如果我们添加其他属性,则需要以正确的顺序放置它们。

This is the order:

这是命令:

font: <font-stretch> <font-style> <font-variant> <font-weight> <font-size> <line-height> <font-family>;

Example:

例:

body {font: italic bold 20px Helvetica;
}section {font: small-caps bold 20px Helvetica;
}

使用@font-face加载自定义字体 (Loading custom fonts using @font-face)

@font-face lets you add a new font family name, and map it to a file that holds a font.

@font-face允许您添加新的字体系列名称,并将其映射到包含字体的文件。

This font will be downloaded by the browser and used in the page, and it’s been such a fundamental change to typography on the web - we can now use any font we want.

该字体将由浏览器下载并在页面中使用,这是对网络排版的根本改变-我们现在可以使用所需的任何字体。

We can add @font-face declarations directly into our CSS, or link to a CSS dedicated to importing the font.

我们可以将@font-face声明直接添加到我们CSS中,或链接到专用于导入字体CSS。

In our CSS file we can also use @import to load that CSS file.

在我们CSS文件中,我们还可以使用@import加载该CSS文件。

A @font-face declaration contains several properties we use to define the font, including src, the URI (one or more URIs) to the font. This follows the same-origin policy, which means fonts can only be downloaded form the current origin (domain + port + protocol).

@font-face声明包含一些用于定义字体的属性,包括src ,字体的URI(一个或多个URI)。 这遵循同源策略,这意味着只能从当前源(域+端口+协议)下载字体。

Fonts are usually in the formats

字体通常采用以下格式

  • woff (Web Open Font Format)

    woff (Web开放字体格式)

  • woff2 (Web Open Font Format 2.0)

    woff2 (网络开放字体格式2.0)

  • eot (Embedded Open Type)

    eot (嵌入式开放式)

  • otf (OpenType Font)

    otf (OpenType字体)

  • ttf (TrueType Font)

    ttf (TrueType字体)

The following properties allow us to define the properties to the font we are going to load, as we saw above:

如下所示,以下属性使我们能够定义将要加载的字体的属性:

  • font-family

    font-family

  • font-weight

    font-weight

  • font-style

    font-style

  • font-stretch

    font-stretch

性能说明 (A note on performance)

Of course loading a font has performance implications which you must consider when creating the design of your page.

当然,加载字体会影响性能,在创建页面设计时必须考虑这些影响。

翻译自: https://flaviocopes.com/css-fonts/

css字体加粗

css字体加粗_CSS字体相关推荐

  1. EasyExcel 设置字体样式(字体、字体大小、字体颜色、字体加粗、字体斜体、字体下划线、字体上标下标、字体删除线)

    1 Maven配置 <!--hutool工具包--><dependency><groupId>cn.hutool</groupId><artifa ...

  2. java font 字体加粗_java字体设置,包括大小,颜色,加粗,下划线,对齐,斜体的设置...

    本文转自:http://www.blogjava.net/Swing/archive/2007/12/26/128965.html 想做一个文本编辑器的朋友,来这里是找对了!! 下面的代码告诉我们该怎 ...

  3. vb语言中怎样编码窗体中所有字体加粗_VB窗口属性中文对照表

    VB 属性对应的中文 A Action 返回或设置被显示的对话框 (CommandDialog) 的类型 , 在设计时无效. ActiveControl 活动控件 ActiveForm 活动窗体 Al ...

  4. android字体加粗的方法

    android字体加粗 android字体加粗  一.英文字体加粗 在xml文件中使用android:textStyle="bold"  二.中字体加粗  不能通过xml文件将中文 ...

  5. html中加粗的字体如何改细,css怎么把字体变细?

    CSS 能够对网页中元素位置的排版进行像素级精确控制,支持几乎所有的字体字号样式,拥有对网页对象和模型样式编辑的能力. 在CSS中,通过 font-weight属性 用来设置字体的粗细值. 该属性用于 ...

  6. 产生粗体字的html标签,html字体加粗用css设置文字粗体样式

    html如何加粗文字,HTML加粗标签元素有哪些?CSS字体加粗又怎么来实现?粗体代码是什么? 综合以上问题,可以使用CSS样式和HTML标签两种方法来实现,在实际布局时候根据需要来选择文字字体加粗方 ...

  7. php 怎么给字体加粗,css怎么把字体加粗加大

    css把字体加粗加大的方法:可以利用font-weight属性来实现,如[font-weight: bold;].font-weight属性用于设置文本的粗细,bold用于定义粗体字符. 相关属性: ...

  8. css 利用阴影给字体加粗

    想要把字体加粗,但是css样式提供的最粗的font-weight:900;也达不到要求时,可以利用css的text-shadow给字体加上多个阴影从而把字体调的更粗一点,当然直接换字体也是可以的. 正 ...

  9. CSS之id和class区别以及字体加粗样式

    字体加粗方式: font-weight: bold; 或者通过值来加粗: font-weight:800; html中对字体加粗的其他方式: <b></b>或<stron ...

  10. html语言怎么让字体加粗,css怎么让字体加粗?

    我们常常对HTML代码中文字字体进行加粗,无论中文.英文.数字以及符合进行加粗布局.下面我们来看一下如何使用css设置字体加粗. css设置字体加粗使用css属性font-weight.该属性用于设置 ...

最新文章

  1. 修改Mysql的root密码方法归纳
  2. mysql left join on_mysql,left join on
  3. IIS6注册.net4.0
  4. rmi java 服务_javaweb项目启动时自动启动rmi服务器实例
  5. 复旦博士用130行代码搞定核酸统计,2分钟解决人工一小时工作量
  6. 使用 JS 实现一个简单的日历
  7. C++经典书籍推荐 .
  8. 腾讯云与玉符科技达成战略合作 共建SaaS生态统一身份认证体系
  9. 已解决:ubuntu-软件更新处无nvidia驱动/ubuntu检测不到扩展屏幕
  10. as常用固定搭配_as 。。。as 一些常考的固定搭配【重点中考】
  11. imx6q的启动方式
  12. CD刻录的一点个人经验:铭大、铼德、三菱、万盛, Nero、Burnatonce、Burrrn、Feurio
  13. 主机开启后,显示器显示NO SIGNAL,无信号
  14. Matlab 动画及Gif生成
  15. Python中的交叉分析pivot_table
  16. 中国企业学习管理系统(LMS)市场趋势报告、技术动态创新及市场预测
  17. 62. 丑数(剑指Offer经典题)
  18. 【从FT到DFT和FFT】(一)从三角函数正交性到傅里叶变换的详细公式推导
  19. 最近两周出去面试遇到的面试题(前端初级、长更)
  20. web前端学习笔记(二)

热门文章

  1. VS2010 visual studio Microsoft 应用程序错误报告 Microsoft Application Error Reporting 下列组件安装失败 1603 1935解决方法
  2. Windows批处理添加注释
  3. 文献解读|DPP-4i治疗诱导的肠道微生物群的改变可改善葡萄糖稳态
  4. python大漠游戏多开_python游戏脚本多开天才生成器
  5. 模拟量输入输出配置及数值的规范化
  6. Revit二次开发——HelloRevitApp
  7. [辅助工具] 【羽睿】Proxmark3 Easy Gui 4.0 5.0 5.1加强版 PM3GUI_X稳定优化版
  8. 在线JS编辑器,可运行保存简单JS代码(已开源)
  9. CentOS7.5安装WPS并解决字体报错
  10. 精选150道iOS面试题