css中可使用font-weight屬性設置文字加粗,只需要給元素添加“font-weight:bold|bolder”樣式即可,值“bold”定義粗體字符,“bolder”定義更粗的字符;還可設置值為700、800或900來實現(xiàn)加粗即可。
本教程操作環(huán)境:windows7系統(tǒng)、CSS3&&HTML5版、Dell G3電腦。
在css中,可以使用font-weight屬性來設置文字加粗效果。
font-weight屬性可以設置文本的粗細,一般用于設置顯示元素的文本中所用的字體加粗
加粗效果相關(guān)的屬性值:
值 | 描述 |
---|---|
bold | 定義粗體字符。 |
bolder | 定義更粗的字符。 |
|
定義由細到粗的字符。400 等同于 normal,而 700 等同于 bold。 |
示例:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>css 文字加粗</title> <style> p.normal { font-weight: normal; } p.bold { font-weight: bold; } p.bolder { font-weight: bolder; } p.thicker { font-weight: 900; } </style> </head> <body> <p class="normal">測試文本!</p> <p class="bold">測試文本!</p> <p class="bolder">測試文本!</p> <p class="thicker">測試文本!</p> </body> </html>
效果圖:
(學習視頻分享:css視頻教程)