CSS文本和字体--笔记回顾

1、文本_text-decoration

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    a{
      text-decoration:none;
      color: #333;
    }
    .taobao{
      color: #00ffff;
    }
    p{
      text-decoration: overline;
    }
    div{
      text-decoration: line-through;
    }
    span{
      text-decoration: underline;
    }
  </style>
</head>
<body>
  <!-- 1.将a元素的下划线清除 -->
  <a href="#">百度一下</a>
  <div>
    <a href="#" class="taobao">淘宝一下</a>
  </div>

  <!-- 2.给其他元素添加装饰线 -->
  <p>hahahaha</p>
  <div>hehehe</div>
  <span>hihihi</span>

  <!-- 3.u元素 -->
  <u>heiheiehei</u>
</body>
</html>

在这里插入图片描述

2、文本_letter-word-spacing

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    .p1{
      letter-spacing: 10px;
      /* letter-spacing: -10px; */
    }
    .p2{
      word-spacing: 10px;
      /* word-spacing: -10px; */
    }
  </style>
</head>
<body>
  <p class="p1">hello world</p>
  <p>hello world</p>
  <p class="p2">hello world</p>
</body>
</html>

在这里插入图片描述

3、文本_text-transform

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    .text1{
      text-transform: capitalize;
    }
    .text2{
      text-transform: uppercase;
    }
    .text3{
      text-transform: lowercase;
    }
  </style>
</head>
<body>
  <div class="text1">hello word</div>
  <div class="text2">hello word</div>
  <div class="text3">Hello Word</div>
</body>
</html>

在这里插入图片描述

4、文本_text-indent

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    p{
      /* px->pixel */
      /* em->1em*20px=20px  相对父类*/
      /* rem->root em  相对根元素*/
      text-indent: 2em;
      font-size: 20px;
    }
  </style>
</head>
<body>
  <p>
    啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
    啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
    啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
    啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
    啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
    啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
    啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
    啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
    啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
    啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
    啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦
  </p>
</body>
</html>

在这里插入图片描述

5、文本_text-align

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    /* left/right/center */
    box1{
      background-color: blue;
      text-align: center;
    }
    box2{
      background-color: purple;
      text-align: center;
    }

    box3{
      background-color: grey;
      text-align: center;
    }
    .inner1{
      background-color: purple;
      width: 200px;
    }

    .box4{
      background-color: #0045fd;
      /* 让内嵌子元素div居中必须先取消其块级特性 */
      text-align: center;
    }
    .inner2{
      background-color: rebeccapurple;
      width: 200px;
      /* 取消块级元素独占一行的特性 */
      display: inline-block;
    }

    /* 2.justify */
    .box5{
      background-color: red;
      color: white;
      width: 500px;

      /* text-align:justify对最后一行没有效果 */
      text-align:justify;
      /* text-align-last: justify;设置最后一行 */
      /* text-align-last: justify; */
    }
  </style>
</head>
<body>
  <!-- left/right/center -->
  <div class="box1">hahahha</div>
  <div class="box2">
    <img src="" alt="">
  </div>

  <div class="box3">
    <!-- div块级元素 -->
    <div class="inner1">hehehehhe</div>
  </div>

  <div class="box4">
    <div class="inner2">hihihihi</div>
  </div>

  <!-- 2.justify -->
  <div class="box5">
    Hello World Hello World Hello World Hello World
    Hello World Hello World Hello World Hello World
    Hello World Hello World Hello World Hello World
    Hello World Hello World Hello World Hello World
    Hello World Hello World Hello World Hello World
    Hello World Hello World Hello World Hello World
    Hello World Hello World Hello World Hello World
    Hello World Hello World Hello World Hello World
    Hello World Hello World Hello World Hello World
    Hello World Hello World Hello World Hello World
  </div>
</body>
</html>

在这里插入图片描述

6、字体_font-size

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    .box{
      font-size: 20px;
    }

    p{
      /* px */
      /* font-size: 24px; */

      /* em单位:1em代表100%,2em代表200%。0.5em代表50% */
      /* font-size中 2em相对于:父元素的font-size*2em=40px*/
      font-size: 2em;

      /* font-size百分比 */
      /* font-size: 50%; */
      /* 谷歌浏览器字体最小是12px */
    }
  </style>
</head>
<body>
  <div class="box">
    <span>span</span>
    <p>hahhahah</p>
  </div>
</body>
</html>

在这里插入图片描述

7、字体_font-family

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    p{
      /* 1.设置网页的字体 */
      /* 默认:font-family: "Microsoft YaHei"; */
      /* font-size: "宋体"; */

      /* 2.设置多种字体,为了防止字体不存在 */
      /* 一般情况下,英文字体只使用于英文,中文字体同时适用英文和中文 */
      /* 若希望中英文分别使用不同的字体,应先把英文字体写在前面,中文字体写在后面 */
      /* 注意:加引号可以防止空格出错 */
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    }
  </style>
</head>
<body>
  <p>hahahahhaha你好</p>
</body>
</html>

在这里插入图片描述

8、字体_font-weight

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    .price{
      color: red;
      /* font-weight: 700; */
      font-weight: bold;
    }
  </style>
</head>
<body>
  <!-- 1.粗体标签 -->
  <!-- strong:700 -->
  <strong>hahhahaha</strong>
  <h1>标题</h1>

  <!-- 2.font-weight (normal:400   bold:700)-->
  <p>
    <span class="price">¥99</span>
  </p>
</body>
</html>

在这里插入图片描述

9、字体_font-style

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    p{
      /* font-style: italic; */
      /* font-style: oblique; */
    }
    
    /* italic:前提是font-family字体支持斜体 */
    .p1{
      font-style: italic;
    }

    /* oblique:让文字倾斜 */
    .p2{
      font-style: oblique;
    }
  </style>
</head>
<body>
  <!-- 1.斜体标签 -->
  <!-- i标签比较常用 (小图标)-->
  <i>hahaha</i>
  <em>hehehe</em>
  <strong></strong>

  <!-- 2.font-style -->
  <p class="p1">hahahahah</p>
  <p class="p2">hehehhehe</p>
</body>
</html>

在这里插入图片描述

10、字体_font-varient

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    .title1{
      font-variant: small-caps;
    }
  </style>
</head>
<body>
  <h1 class="title1">Hello World</h1>
  <h1 class="title2">Hello World</h1>
</body>
</html>

在这里插入图片描述

11、字体_font_line-height

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    div{
      /* 行高=div高度->文字居中 */
      height: 200px;
      line-height: 200px;
      background-color: rosybrown;
    }
  </style>
</head>
<body>
  <!-- 行高:line-height (俩行文字基线之间的间距)-->
  <!-- 行高=文字高度+行距(上下行距平分) -->
  <!-- 作用:让一行文字在div内部垂直居中 -->
  <div>哈哈哈hahahahha哈哈哈</div>
</body>
</html>

在这里插入图片描述

12、字体_font_缩写属性

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    .box1{
      background-color: green;
      /* 有内容时可以用行高(line-height)撑起高度 */
      /* height: 50px; */
      font-size: 30px;
      font-family: "宋体";
      font-weight: 700;
      font-style: italic;
      line-height: 50px;
      font-variant: small-caps;
    }
    /* font的缩写 */
    .box2{
      background-color: green;
      /* font:style varient weight size/line-height family */
      font: italic small-caps bold 30px/50px "宋体";

      /* 
      font: 30px/50px "宋体";
      font: 30px "宋体"; 
      */
    }
    /* 注意
            style、varient、weight可以调换顺序/省略
            /line-height可以省略
            size、family不可以调换顺序,不可以省略
     */
     
  </style>
</head>
<body>
  <div class="box1">hahahha</div>
  <div class="box2">hahahha</div>
</body>
</html>

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值