1. 程式人生 > >box-sizing:border-box,padding-box 顛覆盒子模型

box-sizing:border-box,padding-box 顛覆盒子模型

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="gbk">
    <style type="text/css">
        .base_class {
            width: 100px;
            height: 100px;
            padding: 10px;
            margin: 20px;
            border: 5px solid #ffff00;
            background-color: gray;
        }
    </style>
</head>
<body>
<div class="base_class" style="box-sizing:border-box">border-box</div>
<div class="base_class" style="box-sizing:content-box">content-box 是預設值</div>
<div class="base_class " style="box-sizing:padding-box" >padding-box(firefox支援)</div>
<div class="base_class" style="box-sizing:inherit">繼承父親元素</div>
</body>
</html>