css如何改变字体粗细


本文摘自PHP中文网,作者醉折花枝作酒筹,侵删。

在css中,可以使用font-weight属性改变字体粗细,只需要给字体元素设置“font-weight:数值;”。该属性用于设置显示元素的文本中所用的字体加粗。数字值400相当于关键字normal,700等价于bold。

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

HTML中通过添加<b>标记,或者<strong>标记来设置文字的粗细。

CSS可以将文字的粗细进行了细致的划分,而且,还可以将本身是粗体的文字,变为正常的粗细显示。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

<html>

  <head>

    <title>文字粗细</title>

    <style>

      h1 span {

        font-weight: lighter;

      }

      span {

        font-size: 30px;

      }

      span.one {

        font-weight: 100;

      }

      span.two {

        font-weight: 200;

      }

      span.three {

        font-weight: 300;

      }

      span.four {

        font-weight: 400;

      }

      span.five {

        font-weight: 500;

      }

      span.sex {

        font-weight: 600;

      }

      span.seven {

        font-weight: 700;

      }

      span.eight {

        font-weight: 800;

      }

      span.nine {

        font-weight: 900;

      }

      span.ten {

        font-weight: bold;

      }

      span.eleven {

        font-weight: normal;

      }

    </style>

  </head>

 

  <body>

    <h1>文字<span>粗</span>体</h1>

    <span class="one">文字粗细:100</span>

    <span class="two">文字粗细:200</span>

    <span class="three">文字粗细:300</span>

    <span class="four">文字粗细:400</span>

    <span class="five">文字粗细:500</span>

    <span class="six">文字粗细:600</span>

    <span class="seven">文字粗细:700</span>

    <span class="eight">文字粗细:800</span>

    <span class="nine">文字粗细:900</span>

    <span class="ten">文字粗细:bold</span>

    <span class="eleven">文字粗细:normal</span>

  </body>

</html>

文字的粗细在CSS中通过属性:font-weight设置,如上代码几乎涵盖了所有的文字粗细值,并且,可以是本身是粗体的字体,变成正常粗体。

推荐学习:css视频教程

以上就是css如何改变字体粗细的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

css animation-delay属性怎么用

兼容ie的css写法有哪些

css counter-increment属性怎么用

css里form用法是什么

css max-height属性怎么用

css怎么去掉斜体样式

css 如何实现让文字滑入的方式

css如何禁止滚动条

css怎么设置文字超过隐藏

css怎么设置div的边框样式

更多相关阅读请进入《css》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...