最新消息: 关于Git&GitHub 版本控制你了解多少?
您现在的位置是:群英 > 开发技术 > web开发 >
css中文字的粗细怎样设置?有什么方法?
PHP中文网发表于 2021-09-08 17:38 次浏览

    css中文字的粗细怎样设置?在实际的项目中,我们常会需要设置文字的粗细,例如字体加粗突显内容。HTML中通过添加<b>标记,或者<strong>标记来设置文字的粗细。那么CSS中要怎样实现呢?

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

<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文字粗细
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
相关信息推荐