2.css字体 文本属性

一、字体风格

font-family 字体(比如宋体,微软雅黑)
font-size 字体大小
font-weight 字体粗细(700加粗,400正常)
font-style 字体风格(normal正常,italic倾斜)
符合属性:必须要有大小和字体,其余可有可无
font: 风格 粗细 大小/间距 字体

   <style>
        body {
            font-size: 20px;
        }
        h1 {
            font-family: 'Microsoft YaHei', 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
            font-size: 40px;
            font-weight: 700;
        }
        .ziti {
            font-weight: 700;
        }
        em {
            font-style: normal;
        }
    </style>
<body>
    <h1>40像素,标题标签是特殊的,不会受到body的改变</h1>
    <p>20像素</p>
    <p class="ziti">加粗=700 正常=400</p>
    <em>em标签本身是倾斜的,用font-style: normal变成正常的</em>
</body>

在这里插入图片描述

二、文本属性

颜色color: red/ #FF000/ rgb(255,0,0) 红色
对齐方式text-align: left/ center/ right 文字左 /居 /右中对齐
装饰文本text-decoration:none/ underline/ overline/ line-through 没装饰 下划线 上划线 删除线
首行缩进text-indent: 2em(两个当前文字大小)
行间距line-height: 26px(字+上下间距一起26)

<style>
        h1 {
            text-align: center;
        }
        p {
            color: #337eaf;
            text-decoration: readline;
            text-indent: 2em;
            line-height: 25px;
        }
    </style>
    <h1>文本属性</h1>
    <p>颜色color: red/ #FF000/ rgb(255,0,0) 红色</p>
    <p>对齐方式text-align: left/ center/ right 文字左 //右中对齐</p>
    <p>装饰文本text-decoration:none/ underline/ overline/ line-through 没装饰 下划线 上划线 删除线</p>
    <p>首行缩进text-indent: 2em(两个当前文字大小)</p>
    <p>行间距line-height: 26px(字+上下间距一起26</p>

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值