CSS中设定字体如何设定为微软雅黑Bold字体?

html-css010

CSS中设定字体如何设定为微软雅黑Bold字体?,第1张

1、首先要了解css中是如何控制字体的。\x0d\x0afont:在一个声明中设置所有字体属性;\x0d\x0afont有以下几个属性:\x0d\x0a\x0d\x0afont-style:字体样式\x0d\x0a\x0d\x0afont-variant:字体异体\x0d\x0afont-weight:字体粗细\x0d\x0afont-size/line-height:字体大小/行高\x0d\x0afont-family:字体系列(比如宋体、黑体等)\x0d\x0a2、知道这些之后,那"设定字体为微软雅黑Bold字体"就可以这么写:\x0d\x0afont-family:"微软雅黑"font-weight:bold\x0d\x0a但是需要注意一点,通常我们使用中文字体的时候,都会使用的英文名称,而不是直接使用中文;而且,也会使用简写的形式;如下:\x0d\x0afont:bold12px/1.5em"MicrosoftYaHei"

css中一般是用font-size来设置字体大小。

示例:

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>css字号设置</title>

<style>

div{font-size:16px}

p{font-size:18px}

h2{font-size:20px}

</style>

</head>

<body>

<div>16号字体<div>

<p>18号字体</p>

<h2>20号字体(h2自带字体属性)</h2>

</body>

</html>