在css文件中字体加粗属性为什么

2021-12-10 13:00:47 IT技术网 互联网
浏览

在css文件中,字体加粗属性为“font-weight”,该属性可设置字体文本的粗细程度,当属性值设置为“bold”时可定义粗体字符,设置为“bolder”时可定义更粗的字符。

本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。

在css文件中,字体加粗属性为“font-weight”。

font-weight 属性可设置文本的粗细,支持多种属性值:

描述
normal默认值。定义标准的字符。
bold定义粗体字符。
bolder定义更粗的字符。
lighter定义更细的字符。
  • 100
  • 200
  • 300
  • 400
  • 500
  • 600
  • 700
  • 800
  • 900
定义由细到粗的字符。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>

1.png

(学习视频分享:css视频教程)

以上就是在css文件中字体加粗属性为什么的详细内容,更多请关注dnjidi.com其它相关文章!