<!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>
      .box {
        width: 200px;
        height: 200px;
        border: 2px solid red;
        padding: 20px 30px;
        box-sizing: border-box; /border和padding都归为.box所有/
        background-image: url(https://img.php.cn/upload/article/000/000/003/5f5add2bab403839.png);
        background-position: -100px 100px;
        background-clip: content-box; /理解:center-box,也就是只在.box的实际空间里显示/
      }
      body {
        / 此处的大小是针对全局的,但是优先级比较低 /
        font-size: 20px;
      }
      .em {
        width: 10em;
        height: 10em;
        border: 1px solid green;
        margin-top: 100px;
        font-size: 1em;
        line-height: 10em;
        text-align: center;
      }
      .test {
        / 此处的文字大小是针对此规则集有效,优先级大于body(全局)的文字大小 /
        font-size: 16px;
        height: 10em;
        width: 10em;
        border: 1px solid green;
        margin: 5em 0;
        line-height: 10em;
        background-color: violet;
        padding: 1em;
        / box-sizing: content-box; /
        / 背景裁剪,只在实际区域显示内容(不含padding区域) /
        background-clip: content-box;
      }
    </style>
  </head>
  <body>
    <div class="box">我是box1</div>
    <div class="em">我是em案例</div>
    <div class="test">练习</div>
  </body>
</html>
html全代码不知道怎么用markdown去编写,老师可以在上课的时候可以讲下
                Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号