(얼핏보면 똑같지만 float 속성을 inline-block 속성으로 대체했다.)
저번 포스트에서 float 속성을 써서 레이아웃을 요리조리 만들어보았다.
이번 포스트에서는 float 속성 말고도 가로로 정렬할 때 쓸 수 있는 속성을 써보았다.
- float 속성
- inline-block
inline-block
단점: <태그>
사이에 공백을 제거해야 한다.
공백 제거 방법
<div>
<div class="left-menu"></div>
<!-- -->
<div class="right"></div>
<div>
와 사이에 있는 공백도 0px이 된다.<div style="font-size: 0px;">
<div class="left-menu"></div>
<div class="right"></div>
</div>
<!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>Document</title>
<link rel="stylesheet" href="./layout1.css">
</head>
<body>
<div class="container">
<div class="header"></div>
<div class="left-menu"><p>안녕하세요</p></div><div class="right"></div>
<div class="footer"></div>
</div>
</body>
</html>
// layout.css
.container {
width: 800px;
}
.header {
width: 100%;
height: 50px;
background: #9376E0;
}
.left-menu {
width: 20%;
height: 400px;
background: #E893CF;
/* float: left; */
display: inline-block;
vertical-align: top;
}
.right {
width: 80%;
height: 400px;
background: #F3BCC8;
/* float: left; */
display: inline-block;
}
.footer {
width: 100%;
height: 100px;
background: #F6FFA6;
/* clear: both; */
}