CSS3新增的box-sizing属性

content-box:设置内容区的宽和高
border-box:设置内容区加填充区加边框区的宽和高

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div style="width:200px; height: 100px;background-color: #ddd;
    background-clip: content-box;
    border: 20px solid #555;
    padding: 20px;
    box-sizing: content-box;">
    </div><br>
    <div style="width:200px; height: 100px;background-color: #ddd;
    background-clip: content-box;
    border: 20px solid #555;
    padding: 20px;
    box-sizing: border-box;">
    </div>
</body>
</html>

显示:
CSS3新增的box-sizing属性_第1张图片

你可能感兴趣的:(CSS3新增的box-sizing属性)