css中可利用font-weight屬性來讓元素不加粗,寫法為“元素{font-weight:normal;}”;font-weight屬性用于設置文本的粗細樣式,當值設置為“normal”時,元素會被設成標準字符樣式,也就是不加粗的樣式。
本教程操作環(huán)境:windows10系統(tǒng)、CSS3&&HTML5版、Dell G3電腦。
css中不加粗怎么寫
在css中可以利用font-weight屬性來給元素設置不加粗的樣式,font-weight屬性用于設置文本的粗細。
屬性值如下圖所示:
下面我們通過示例來看一下怎樣使元素不加粗,示例如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style type="text/css"> p {font-weight: bold} </style> </head> <body> <p class="normal">這一段不想加粗</p> <p>This is a paragraph</p> <p>This is a paragraph</p> </body> </html>
輸出結果:
此時并不想讓其中一段話加粗,只需要給這段話添加font-weight: normal樣式即可:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style type="text/css"> p {font-weight: bold} p.normal {font-weight: normal} </style> </head> <body> <p class="normal">這一段不想加粗</p> <p>This is a paragraph</p> <p>This is a paragraph</p> </body> </html>
輸出結果:
(學習視頻分享:css視頻教程)