官术网_书友最值得收藏!

Using custom fonts to improve page design

Now that we know how to add custom fonts, let's apply some to our content. We'll use a sans serif font, PT Sans, for our navigation links, and a serif font, Droid Serif, for our main paragraph text (both chosen from Google Fonts). First, we'll add the include-link that Google Fonts generated when we chose the fonts; this gets added to the head of the page (/ch3/fonts.html):

<link  rel="stylesheet">

Now we just have to apply these to the relevant elements of our page. For the navigation links, use the following:

.primary-nav li {
font-family: "PT Sans", sans-serif;
}

And we'll apply Droid Serif to all other text:

body {
font-family: "Droid Serif", serif;
}

Finally, let's stick with Georgia for our logo and h1 texts. Note that we don't need to include Georgia explicitly, as it's available on most systems, but we can provide a fallback in any case:

.logo, h1 {
font-family:Georgia, "Times New Roman", serif;
}

This resulting page should look something like the following image:

Article page showing custom web fonts, and some text effects we'll learn about shortly (/ch3/fonts.html)
You may have seen the amp-font component already, and you might be wondering what it's for. You don't need amp-font to include custom fonts, but you can use it to define timeouts and fallback for when custom fonts fail to load.
主站蜘蛛池模板: 凤翔县| 平南县| 锦州市| 澜沧| 临澧县| 诸暨市| 大邑县| 安徽省| 兰州市| 余姚市| 岗巴县| 锡林浩特市| 岢岚县| 靖西县| 灯塔市| 永修县| 潼南县| 台北市| 从江县| 健康| 新疆| 湖口县| 南澳县| 通城县| 宜城市| 台山市| 宣城市| 桦南县| 泽州县| 靖远县| 石景山区| 吉木萨尔县| 临高县| 商都县| 新河县| 阿图什市| 安多县| 南雄市| 东乡| 获嘉县| 陈巴尔虎旗|