07css3盒模型.html

02-CSS基础与进阶-day6_2018-09-05-21-51-42

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
       div:nth-child(1) {
              width: 200px;
              height: 200px;
              background-color: red;
              /* box-sizing: content-box; 默认值 以前标准盒模型 */
              padding: 10px;
              border: 10px solid #000;
              /*盒子实际宽 width+padding+border*/
       }
       div:nth-child(2) {
              width: 200px; /*此时width代表盒子真正的宽度 不是内容的宽度*/
              height: 200px;
              background-color: purple;
              box-sizing: border-box; /* padding border不会撑开盒子 */
              padding: 20px;
              border: 10px solid #000;
              /*盒子实际宽 width包含padding+border+内容*/
       }
    </style>
</head>
<body>
    <div></div>
    <div></div>
</body>
</html>

 

相关文章:

  • 2021-05-22
  • 2021-09-07
  • 2021-08-21
  • 2021-05-25
  • 2021-04-01
  • 2021-07-20
  • 2021-08-08
  • 2021-09-01
猜你喜欢
  • 2021-10-04
  • 2021-04-11
  • 2021-09-09
  • 2021-10-02
  • 2021-05-30
  • 2022-01-22
  • 2021-04-10
相关资源
相似解决方案