CSS学习笔记3:字体样式

13 篇文章 0 订阅

字体类型

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>字体类型</title>
    <!--font-family	字体类型-->
    <style>
        #div1 {
            font-family: Arial;
        }
        /*字体类型是多个英文单词或者中文,需要加上双引号*/
        #div2 {
            font-family: "Times New Roman";
        }

        #div3 {
            font-family: "Heiti SC";
        }
        /*可以指定多种字体,以逗号分隔*/
        /*如果没有指定的字体,则按从左往右的优先级选择字体,*/
        p {
            font-family: Arial, Verdana, Georgia;
        }
    </style>
</head>
<body>
<div id="div1">Arial</div>
<div id="div2">Times New Roman</div>
<div id="div3">黑体</div>
<p>Rome was not built in a day.</p>
</body>
</html>

在这里插入图片描述

字体大小

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>字体大小</title>
    <!--font-size	字体大小-->
    <!--font-size   取值单位不仅仅是px,还有em、百分比等-->
    <style>
        #p1 {
            font-size: 10px;
        }

        #p2 {
            font-size: 15px;
        }

        #p3 {
            font-size: 20px;
        }
    </style>
</head>
<body>
<p id="p1">字体大小为10px</p>
<p id="p2">字体大小为15px</p>
<p id="p3">字体大小为120px</p>
</body>
</html>

在这里插入图片描述

字体粗细

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>字体粗细</title>
    <!--font-weight	字体粗细-->
    <!--lighter	    较细-->
    <!--normal	    正常(默认值)-->
    <!--bold	    较粗-->
    <!--bolder	    很粗(其实效果跟bold差不多)-->
    <style>
        /* font-weight取值分为数值与关键字 */
        /* 一般使用关键字 */
        #p1 {
            font-weight: 100;
        }

        #p2 {
            font-weight: 400;
        }

        #p3 {
            font-weight: 700;
        }

        #p4 {
            font-weight: 900;
        }

        #p11 {
            font-weight: lighter;
        }

        #p22 {
            font-weight: normal;
        }

        #p33 {
            font-weight: bold;
        }

        #p44 {
            font-weight: bolder;
        }

    </style>
</head>
<body>
<!--数值-->
<p id="p1">字体粗细为100(lighter)</p>
<p id="p2">字体粗细为400(normal)</p>
<p id="p3">字体粗细为700(bold)</p>
<p id="p4">字体粗细为900(bolder)</p>
<br/>
<!--关键字-->
<p id="p11">字体粗细为lighter</p>
<p id="p22">字体粗细为normal</p>
<p id="p33">字体粗细为bold</p>
<p id="p44">字体粗细为bolder</p>
</body>
</html>

在这里插入图片描述

字体风格

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>字体风格</title>
    <!--font-style	字体风格-->
    <!--normal	正常(默认值)-->
    <!--italic	斜体-->
    <!--oblique	斜体-->
    <!--有些字体有斜体italic属性,但有些字体却没有italic属性。
    oblique是让没有italic属性的字体也能够有斜体效果-->
    <style>
        #p1 {
            font-style: normal;
        }

        #p2 {
            font-style: italic;
        }

        #p3 {
            font-style: oblique;
        }
    </style>
</head>
<body>
<p id="p1">字体风格为normal</p>
<p id="p2">字体风格为italic</p>
<p id="p3">字体风格为oblique</p>
</body>
</html>

在这里插入图片描述

字体颜色

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>字体颜色</title>
    <!--color	字体颜色-->
    <style>
        /* color取值分为关键字与16进制RGB值 */
        #p1 {
            color: gray;
        }

        #p2 {
            color: orange;
        }

        #p3 {
            color: red;
        }

        #p11 {
            color: #03FCA1;
        }

        #p22 {
            color: #048C02;
        }

        #p33 {
            color: #CE0592;
        }
    </style>
</head>
<body>
<p id="p1">字体颜色为灰色</p>
<p id="p2">字体颜色为橙色</p>
<p id="p3">字体颜色为红色</p>
<p id="p11">字体颜色为#03FCA1</p>
<p id="p22">字体颜色为#048C02</p>
<p id="p33">字体颜色为#CE0592</p>
</body>
</html>

在这里插入图片描述

练习

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Practice</title>
    <style>
        #p1 {
            font-family: Arial, Verdana, Georgia;
            font-size: 14px;
            font-weight: bold;
            color: blue;
        }
    </style>
</head>
<body>
<p id="p1">有规划的人生叫蓝图,没规划的人生叫拼图。</p>
</body>
</html>

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值