position ์์ฑ์ ์์๋ค์ ํน์ ์์น์ ๊ณ ์ ๋์ด ์๋๋ก ๋ง๋ค ๋ ์ ์ฉํ๊ฒ ์ฐ์ธ๋ค.
<div style="width: 100px; height: 100px; background-color: yellow;">div1</div>
<div style="width: 100px; height: 100px; background-color: greenyellow;"> div2</div>
top, right, left, bottom
์ผ๋ก ์๋ ์์น์์ ์ผ๋ง๋ ๋ฉ์ด์ง ์ง ์ ํ๋ค. (margin ๊ฐ์ ๋๋)<div style="
width: 100px;
height: 100px;
background-color: yellow;">
div1
</div>
<div style="
width: 100px;
height: 100px;
background-color: greenyellow;
position: relative;
top: 100px;
left: 100px;">
div2
</div>
์๋ ์์น์ ์๋ ์์น!
<div style="
width: 300px;
height: 300px;
background-color: yellow;
position: relative;">
<div style="background-color: greenyellow">๊ธฐ๋ณธ ์์น</div>
<div
style="
position: absolute;
background-color: antiquewhite;
top: 100px;
left: 100px;
width: 100px;
height: 100px;">
absolute ์์
</div>
</div>
<body style="height: 500px;">
<div style="
width: 80%;
height: 100px;
background-color: antiquewhite;
position: fixed;">
๋ค๋น๊ฒ์ด์
๋ฐ
</div>
</body>
<body style="height: 2000px;">
<div style="
width: 80%;
height: 100px;
background-color: antiquewhite;
position: fixed;">
fixed
</div>
<div style="
width: 300px;
height: 100px;
background-color: lightskyblue;
position: sticky;
top: 0px;
margin-top:200px;
float:right;">
sticky
</div>
</body>
[์ถ์ฒ]