首先,要知道box-sizing是用来干啥的:改变盒模型中宽度和高度的定义范围。
border-box: width = content + padding + border ,也就是IE的盒怪异模式。
content-box:width = content 正常模式
使用场景分析:当需要以content + padding + border为整体的时候使用border-box,例如:底部菜单栏等
以content padding border为一个整体来设置宽高度时。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>box-sizing使用场景分析</title>
</head>
<style>
#menu-footer{
position: fixed;
bottom: 0;
height: 100px;
display: flex;
width: 100%;
}
.btn{
padding: 10px;
width: calc(100% / 3);
background-color: red;
}
</style>
<body>
<div id="menu-footer">
<div class="btn">
首页
</div>
<div class="btn">
设置
</div>
<div class="btn">
个人
</div>
</div>
</body>
</html>