CSS教程
CSS进阶

CSS font-weight

CSS font-weight属性用于定义文本的粗细,粗细程度取决于浏览器使用的字体系列。
语法
font-weight: normal | lighter | bolder | bold | number | inherit |initial | unset;
属性值
normal:这是默认字体粗细,其数字值为400。
lighter:它考虑字体族的现有字体粗细,并使字体粗细与父元素相比更轻。
bolder:考虑 font-family 的现有字体粗细,并使字体粗细与父元素相比更大。
bold:顾名思义,它用于定义粗体字体粗细,其数值为700。
number:基于指定数字的字体粗细。其范围可以在1到1000之间。
initial:它用于将字体粗细设置为其默认值。
让我们看一个示例
示例
<!DOCTYPE html>
<html>
<head>
    <title> font-weight property </title>
    <style>
        body{
            font-family: sans-serif;
        }
        p.one{
            font-weight: normal;
        }
        p.two{
            font-weight: lighter;
        }
        p.three{
            font-weight: bolder;
        }
        p.four{
            font-weight: bold;
        }
        p.five{
            font-weight: 1000;
        }
        p.six{
            font-weight: initial;
        }
        p.seven{
            font-weight: inherit;
        }
        p.eight{
            font-weight: unset;
        }
    </style>
</head>
<body>
    <p class="one">
       normal property value
    </p>
    <p class="two">
      lighter property value
    </p>
    <p class="three">
      bolder property value
    </p>
    <p class="four">
      bold property value
   </p>
   <p class="five">
      number property value
   </p>
    <p class="six">
      initial property value
    </p>
    <p class="seven">
      inherit property value
    </p>
    <p class="eight">
      unset property value
    </p>
</body>
</html>

normal属性字体粗细

lighter属性字体粗细

bolder属性字体粗细

bold属性字体粗细

number属性字体粗细

initial属性字体粗细

inherit属性字体粗细

unset属性字体粗细

昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4