【CSS】盒模型

玉字璧

关注

阅读 47

2022-03-24

概念

例题:求ie标准盒模型和w3c盒模型红色区域的宽度和高度

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>test</title>
  <style>
    .box{
        width:100px;
        height:100px;
        background:red;
        padding:10px;
        border:20px blue solid;
        margin:10px;
        }

    #border-box{
        box-sizing: border-box;
        }

    #content-box{
        box-sizing: content-box;
        }
  </style>
</head>
<body>
<div>
  <div class='box' id="border-box"></div>
  <div class='box' id="content-box"></div>
</div>
</body>
</html>

运行:

 

精彩评论(0)

0 0 举报