在CSS中,字體粗細(xì)可用font-weight屬性來修改,只需要將font-weight屬性的值設(shè)置為“bold”、“bolder”、“l(fā)ighter”或“500”、“600”、“700”、“800”、“900”值即可,屬性值越大字體越粗。
本教程操作環(huán)境:windows7系統(tǒng)、CSS3&&HTML5版、Dell G3電腦。
在CSS中,字體粗細(xì)可以使用font-weight屬性來修改。
CSS font-weight屬性
font-weight屬性可以用于設(shè)置文本文字的粗細(xì)。屬性值越大字體越粗。
屬性值:
值 | 描述 |
---|---|
normal | 默認(rèn)值。定義標(biāo)準(zhǔn)的字符。 |
bold | 定義粗體字符。 |
bolder | 定義更粗的字符。 |
lighter | 定義更細(xì)的字符。 |
|
定義由細(xì)到粗的字符。400 等同于 normal,而 700 等同于 bold。 |
【推薦教程:CSS視頻教程 】
示例:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>css 文字加粗</title> <style> .a1{ font-weight:100; } .a2{ font-weight:200; } .a3{ font-weight:300; } .a4{ font-weight:400; } .a5{ font-weight:500; } .a6{ font-weight:600; } .a7{ font-weight:700; } .a8{ font-weight:800; } .a9{ font-weight:900; } </style> </head> <body> <div> <p>這是一段測(cè)試文字--默認(rèn)粗細(xì)</p> <p class="a1">這是一段測(cè)試文字</p> <p class="a2">這是一段測(cè)試文字</p> <p class="a3">這是一段測(cè)試文字</p> <p class="a4">這是一段測(cè)試文字</p> <p class="a5">這是一段測(cè)試文字</p> <p class="a6">這是一段測(cè)試文字</p> <p class="a7">這是一段測(cè)試文字</p> <p class="a8">這是一段測(cè)試文字</p> <p class="a9">這是一段測(cè)試文字</p> </div> </body> </html>