<div class="box" id="one">One</div>
<div class="box" id="two">Two</div>
<div class="box" id="three">Three</div>
.box {
display: inline-block;
width: 100px;
height: 100px;
background: black;
color: white;
}
#two {
position: relative;
top: 20px;
left: 20px;
background: green;
}
<div class="box" id="one">One</div>
<div class="box" id="two">Two</div>
<div class="box" id="three">Three</div>
.box {
display: inline-block;
width: 100px;
height: 100px;
background: black;
color: white;
}
#two {
position: absolute;
top: 20px;
left: 20px;
background: green;
}
화면이 렌더링 되었을때 어떠한 특정 영역이 표시 되는데 성질을 부여하는 property이다.
대표적으로 block 요소와 inline 요소로 나눌 수 있다.
block은 한 영역을 차지 하는 박스형태의 성질을 가진다. 그래서 기본적으로 block은 width값이 100%가 되고, 라인이 새로 추가된다!
width와 height 값을 지정 할 수 있다.
padding과 margin 값을 지정 할 수 있다.
inline은 주로 텍스트를 넣을 때 사용 되는 형태이다. 그래서 기본적으로 content 영역 만큼 자동으로 잡히게 되며 라인이 새로 추가 되지 않는다.
width와 height 값을 지정 할 수 없다.
margin-top, margin-bottom 적용 할 수 없다.
inline-block은 inline, block 특징을 모두 가진 형태이다.
줄바꿈이 되지 않는다.
width와 height 값을 지정 할 수 있다.
width와 height 값을 지정하지 않을 경우, inline처럼 content 영역만 잡히게 된다.