2.2-CSS基础--font 字体大小、粗细、样式

字体大小:font-size

  • 需设置单位,否则无效
  • 数字+px
  • Chrome浏览器默认16px大小
<!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>
        p {
            font-size: 40px;
        }
    </style>
</head>
<body>
    <p>我是一个标签</p>
</body>
</html>

字体粗细:font-weight

  • 取值:
    纯数字:100~900 的整百数

    • 正常: 400
    • 加粗: 700

    关键字:

    • 正常: normal
    • 加粗: bold
    • 不是所有字体都提供了九种粗细,因此部分取值页面中无变化
<!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>
        p {
            font-weight: 700;
        }
    </style>
</head>
<body>
    <p>我是一个标签</p>
</body>
</html>

字体样式(是否倾斜):font-style

  • 取值:
    • 正常(默认值): normal
    • 倾斜: italic
<!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>
        p {
            font-style: italic;
        }
    </style>
</head>
<body>
    <p>我是一个标签</p>
</body>
</html>

字体类型:font-family

  • 取值:字体11,字体2,字体3,字体4;
  • 字体系列:sans-serif、serif、monospace等。
<!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>
        p {
            font-family: 微软雅黑,楷体,宋体,sans-serif;
        }
    </style>
</head>
<body>
    <p>我是一个标签</p>
</body>
</html>
  • 渲染规则:
    • 从左往右按照顺序查找,如果电脑中未安装该字体,则显示下一个字体
    • 如果都不支持,此时会根据操作系统,显示最后字体系列的默认字体

字体类型:font 属性连写

  • 属性名:font
  • 取值:font:style weight size family;
  • 顺序要求:style weight size family
  • 省略要求:只能省略前两个

在这里插入图片描述

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

秋枫 ~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值