HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>padding - box-sizing </title>
<link rel="stylesheet" href="css/03_padding_box.css">
</head>
<body>
<center><h1>padding에는 box-sizing 고려</h1></center>
<div class="container">
<!-- .item.box${$}*2 -->
<div class="item box1">1</div>
<div class="item box2">2</div>
</div>
</body>
</html>
HTML
복사
CSS
.container {
position: relative;
width: 1200px;
border: 3px dashed orange;
text-align: center;
}
.item {
width: 100px;
height: 100px;
line-height: 100px;
border: 1px solid gray;
background-color: #ddd;
}
.box1 {
padding: 20px;
box-sizing: content-box;
/* content-box : 컨텐츠 크기만 박스의 크기로 지정 */
}
.box2 {
padding: 20px;
line-height: 60px;
box-sizing: border-box;
/* border-box : content+padding+border 를 크기로 지정 */
}
CSS
복사