LOVEJOAN

文章 分类 评论
76 9 1453

站点介绍

人生是一场孤独的旅行,没有终点。。。

CSS基础二-文字控制属性

chuck 2023-07-10 284 15条评论 网页设计 html

首页 / 正文

文字控制属性

属性描述
font-size 调整字体大小
font-weight 调整字体粗细
font-style 字体倾斜
line-height 行高
font-family 字体类型
font 复合属性
text-indent 文本缩进
text-align 文本对齐方式
text-decoration 修饰线
color 文字颜色

字体大小

属性名称:font-size

属性值:文字尺寸,PC端常见单位为像素px

<style>
        p {
            font-size: 30px;
        }
</style>

字体粗细

属性名:font-weight

属性值:数字400(正常),700(加粗),关键字normal(正常),bold(加粗)

p {
            font-size: 25px;
            font-weight: bold;
            font-weight: 700;
        }

字体倾斜

属性名:font-style

属性值:normal(正常),italic(倾斜)

可以用于清除字体默认的倾斜效果。

    <style>
        h3 {
            font-weight: 400;
        }
        div {
            font-weight: 700;
        }
        em {
            font-style: normal;
        }
    </style>

行高

用于设置多行文本之间的间距。

属性名:line-height

属性值:数字+px或者数字(当前font-size属性值的倍数)

    <style>
        p {
            line-height: 1.5;
            line-height: 20px;
        }
    </style>

设置行高垂直居中。设置line-height等于盒子的height,只适用于单行文字。

    <style>
        div {
            height: 100px;
            background-color:skyblue;
            line-height: 100px;
            text-align: center;
        }
    </style>

字体族

属性名:font-family

属性值:字体名

    <style>
        div {
            height: 100px;
            background-color:skyblue;
            line-height: 100px;
            text-align: center;
            font-family: 宋体;
        }
    </style>

font复合属性

属性的简写方式,一个属性对应多个值,空格隔开。

font:是否倾斜 是否加粗 字号/行高 字体;(必须按顺序书写)

字号和字体必须填写否则不生效。

    <style>
        div {
            font: italic 400 20px/1.5 宋体;
        }
    </style>

文本修饰属性

文本缩进:

text-indent

属性值:数字+px或者数字+em(1em=当前标签的字号大小)推荐使用。

    <style>
        div {
            text-indent: 2em;
        }
    </style>

文本对齐:

text-align

属性值:left(左对齐默认)center(居中对齐)right(右对齐)

    <style>
        div {
            text-align: center;
        }
    </style>

文本修饰线:

text-decoration

属性值:

属性值效果
none
underline下划线
line-through删除线
overline上划线
    <style>
        div {
            text-decoration:underline;
        }
    </style>

文字颜色

属性名:color

值:

颜色表示属性值说明
颜色关键字英文单词,测试用red,green,blue
rgbrgb(r,g,b)取三原色,0-255
rgbargba(r,g,b,a)a表示透明,取值0-1,实现透明色
十六进制表示#RRGGAA#0000000,开发使用,设计稿复制使用

RGB颜色对照:

RGB颜色对照表

浏览器调试工具

F12或者右键检查打开调试工具。

如果出现黄色感叹号代码代码有错误。

评论(15)

  1. 1 游客 2025-03-27 23:37 回复

    555

  2. 1 游客 2025-03-27 23:36 回复

    5557mV4K2OU') OR 669=(SELECT 669 FROM PG_SLEEP(15))--

  3. 1 游客 2025-03-27 23:35 回复

    5550"XOR(555*if(now()=sysdate(),sleep(15),0))XOR"Z

  4. 1 游客 2025-03-27 23:34 回复

    555

  5. 1 游客 2025-03-27 23:33 回复

    555

  6. 1 游客 2025-03-27 23:32 回复

    555

  7. 1 游客 2025-03-27 23:31 回复

    555

  8. 1 游客 2025-03-27 23:27 回复

    555

  9. 1aaHNh7UI'; waitfor delay '0:0:15' -- 游客 2025-03-27 23:26 回复

    555

  10. 1VItQlp41 游客 2025-03-27 23:25 回复

    555

  11. 1 游客 2025-03-27 23:24 回复

    555

  12. 19759140 游客 2025-03-27 23:22 回复

    555

  13. 1hiv8EYhVO 游客 2025-03-27 23:21 回复

    555

  14. 1 游客 2025-03-27 23:21 回复

    555

  15. 1 游客 2025-03-27 23:21 回复

    555

热门文章

最新评论

  • 1

    555fulIdEqZ' OR 160=(SELECT 160 FROM PG_SLEEP(15))--

  • 1

    555-1)) OR 58=(SELECT 58 FROM PG_SLEEP(15))--

  • 1

    555-1) OR 13=(SELECT 13 FROM PG_SLEEP(15))--

  • 1

    555-1 OR 475=(SELECT 475 FROM PG_SLEEP(15))--

  • 1

    555

  • 1

    555

  • 1

    5554FobGRsu') OR 696=(SELECT 696 FROM PG_SLEEP(15))--

  • 1

    555C9F0upP1' OR 504=(SELECT 504 FROM PG_SLEEP(15))--

  • 1

    555

  • 1-1; waitfor delay '0:0:15' --

    555

日历

2025年05月

    123
45678910
11121314151617
18192021222324
25262728293031

文章目录