<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>怪异盒子的概念</title>
<style>
/*
怪异盒子的宽度是加内边距和边框
box-sizing
可选值:
content-box{默认值}
border-box{挤压内部}
*/
.box1{
width: 200px;
height: 200px;
background-color: red;
padding: 30px;
border: 10px solid black;
/*标准盒模型*/
box-sizing: content-box;
}
.box2{
width: 200px;
height: 200px;
background-color: green;
margin-top: 100px;
padding: 30px;
border: 10px solid black;
/*怪异盒模型*/
box-sizing: border-box;
}
</style>
</head>
<body>
<div class="box1"></div>
<div class="box2"></div>
</body>
</html>
版权属于:
yu
作品采用:
《
署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)
》许可协议授权
评论 (0)