CSS04:字体属性

1、color 字体颜色

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>

        #word{
            /* 1、字母单词 */
            color: red;

            /* 2、16进制表示法 */
            color: #984700;

            /* 3、三原色通道 */
            color: rgb(122, 155, 77);

            /* 4、rgba,a代表阿尔法通道透明度 */
            color: rgba(122, 155, 77, 0.3);
        }
    </style>
</head>
<body>
    
    <p>默认字体属性</p>
    <p id="word">自定义字体属性</p>

</body>
</html>

依次对比效果:

 


2、font-size 设置文本大小 

浏览器能接受最小字体是12px,后面要得到更小字体可通过缩放实现。 

#word{
            color: rgb(122, 155, 77);
            font-size: 50px;
        }


3、font-weight 文本粗细 

描述

bold定义粗体字符
bolder定义更粗的字符
ligher定义更细的字符
100~900定义由细到粗,400等同默认,700等同于bold


4、font-style 指定字体样式

描述
normal

默认值

italic斜体字

5、font-family 指定一个元素的字体

tips:

① 每个值用逗号分开

② 如果字体名称包含空格,它必须加上引导


总体效果演示:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

        #word{
            color: rgb(122, 155, 77);
            font-size: 50px;
            font-weight: lighter;
            font-style: italic;
            font-family: "宋体";
        }
    </style>
</head>
<body>
    
    <p>默认字体属性</p>
    <p id="word">自定义字体属性</p>

</body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值