返回到:CSS 字体 | CSS教程
属性定义及使用说明
font-weight 属性设置文本的粗细
默认值: | normal |
---|---|
继承: | yes |
版本: | CSS1 |
JavaScript 语法: | object.style.fontWeight=”900″ |
属性值
值 | 描述 |
---|---|
normal | 默认值。定义标准的字符。 |
bold | 定义粗体字符。 |
bolder | 定义更粗的字符。 |
lighter | 定义更细的字符。 |
100 200 300 400 500 600 700 800 900 | 定义由细到粗的字符。400 等同于 normal,而 700 等同于 bold。 |
inherit | 规定应该从父元素继承字体的粗细。 |
浏览器支持
表格中的数字表示支持该属性的第一个浏览器版本号。
属性 | 谷歌 | IE | 火狐 | 苹果 | opera |
---|---|---|---|---|---|
font-weight | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
实例
三段文字设置不同的字体粗细:
HTML
x
21
21
1
2
<html>
3
<head>
4
<meta charset="utf-8">
5
<title>Web176教程(web176.com)</title>
6
<style>
7
p.normal {font-weight:normal;}
8
p.light {font-weight:lighter;}
9
p.thick {font-weight:bold;}
10
p.thicker {font-weight:900;}
11
</style>
12
</head>
13
14
<body>
15
<p class="normal">This is a paragraph.</p>
16
<p class="light">This is a paragraph.</p>
17
<p class="thick">This is a paragraph.</p>
18
<p class="thicker">This is a paragraph.</p>
19
</body>
20
21
</html>
阅读剩余 54%
作者:terry,如若转载,请注明出处:https://www.web176.com/cssprop/5701.html