html中設(shè)置字體的屬性:font、font-family、font-size、font-style、font-variant、font-weight、“@font-face”、font-size-adjust、font-stretch。

本教程操作環(huán)境:windows7系統(tǒng)、CSS3&&HTML5版、Dell G3電腦。
字體屬性定義字體,加粗,大小,文字樣式。
html中設(shè)置字體的屬性
| 屬性 | 說明 |
|---|---|
| font | 在一個(gè)聲明中設(shè)置所有字體屬性 |
| font-family | 規(guī)定文本的字體系列 |
| font-size | 規(guī)定文本的字體尺寸 |
| font-style | 規(guī)定文本的字體樣式 |
| font-variant | 規(guī)定文本的字體樣式。設(shè)置小型大寫字母的字體顯示文本,這意味著所有的小寫字母均會(huì)被轉(zhuǎn)換為大寫,但是所有使用小型大寫字體的字母與其余文本相比,其字體尺寸更小。 |
| font-weight | 規(guī)定字體的粗細(xì) |
| @font-face | 一個(gè)規(guī)則,允許網(wǎng)站下載并使用其他超過"Web- safe"字體的字體 |
| font-size-adjust | 為元素規(guī)定 aspect 值。為某個(gè)元素規(guī)定一個(gè) aspect 值,這樣就可以保持首選字體的 x-height。 |
| font-stretch | 收縮或拉伸當(dāng)前的字體系列。對當(dāng)前的 font-family 進(jìn)行伸縮變形。所有主流瀏覽器都不支持。 |
擴(kuò)展資料:
在HTML/CSS中,有兩種類型的字體系列名稱:
-
通用字體系列 – 擁有相似外觀的字體系統(tǒng)組合(如 "Serif" 或 "Monospace")
-
特定字體系列 – 一個(gè)特定的字體系列(如 "Times" 或 "Courier")
| Generic family | 字體系列 | 說明 |
|---|---|---|
| Serif | Times New Roman Georgia |
Serif字體中字符在行的末端擁有額外的裝飾 |
| Sans-serif | Arial Verdana |
"Sans"是指無 – 這些字體在末端沒有額外的裝飾 |
| Monospace | Courier New Lucida Console |
所有的等寬字符具有相同的寬度 |
font-family 屬性應(yīng)該設(shè)置幾個(gè)字體名稱作為一種"后備"機(jī)制,如果瀏覽器不支持第一種字體,他將嘗試下一種字體。
注意: 如果字體系列的名稱超過一個(gè)字,它必須用引號,如Font Family:"宋體"。
多個(gè)字體系列是用一個(gè)逗號分隔指明:
p{font-family:"Times New Roman", Times, serif;}
下面是一些常用的字體組合,通用的字體系列。
Serif 字體
| 字體 | 文本示例 |
|---|---|
| Georgia, serif |
This is a headingThis is a paragraph |
| "Palatino Linotype", "Book Antiqua", Palatino, serif |
This is a headingThis is a paragraph |
| "Times New Roman", Times, serif |
This is a headingThis is a paragraph |
sans – serif字體
| 字體 | 文本示例 |
|---|---|
| Arial, Helvetica, sans-serif |
This is a headingThis is a paragraph |
| Arial Black, Gadget, sans-serif |
This is a headingThis is a paragraph |
| "Comic Sans MS", cursive, sans-serif |
This is a headingThis is a paragraph |
| Impact, Charcoal, sans-serif |
This is a headingThis is a paragraph |
| "Lucida Sans Unicode", "Lucida Grande", sans-serif |
This is a headingThis is a paragraph |
| Tahoma, Geneva, sans-serif |
This is a headingThis is a paragraph |
| "Trebuchet MS", Helvetica, sans-serif |
This is a headingThis is a paragraph |
| Verdana, Geneva, sans-serif |
This is a headingThis is a paragraph |
Monospace 字體
| 字體 | 文本示例 |
|---|---|
| "Courier New", Courier, monospace |
This is a headingThis is a paragraph |
| "Lucida Console", Monaco, monospace |
This is a headingThis is a paragraph |
(學(xué)習(xí)視頻分享:css視頻教程)
站長資訊網(wǎng)