CSS盒子模型

1、内容盒子(W3C盒子、标准盒子)

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .contentDiv{
            width: 100px;
            height: 100px;
            background-color: pink;
            margin: 10px 20px 30px;
            padding: 13px 27px 32px;
            border: 5px solid red;
        }
    </style>
</head>
<body>
    <div class="contentDiv">内容盒子</div>
</body>
</html>

 

        内容盒子计算公式

        盒子宽 内容区宽+左右内边距+左右边框 100px+27px+27px+5px+5px=164px

        盒子高 内容区高+上下内边距+上下边框 100px+13px+32px+5px+5px=155px

        盒子所占页面空间宽 盒子宽+左右外边距 164px+20px+20px=204px

        盒子所占页面空间高 盒子高+上下外边距 155px+10px+30px=195px

2、边框盒子(怪异盒子、IE盒子)

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .borderDiv{
            /* 设置盒模型 box-sizing content-box(默认值)borer-box(边框盒子) */
            box-sizing: border-box;
            width: 100px;
            height: 100px;
            border: 3px solid blue;
            margin: 10px 28px 29px;
            padding: 12px 19px 27px;
        }
    </style>
</head>
<body>
    <div class="borderDiv">边框盒子</div>
</body>
</html>

 

        边框盒子计算公式

        盒子宽 width 100px = 内容区宽+左右内边距+左右边框

        盒子高 height 100px= 内容区高+上下内边距+上下边框

        盒子所占页面空间宽 盒子宽+左右外边距 100px+28px+28px=156px

        盒子所占页面空间高 盒子高+上下外边距 100px+17px+39px=156px

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

紫玫瑰ABU

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值