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