์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” CSS๋ฅผ ์ด์šฉํ•œ ์œ„์น˜ ์„ค์ •์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

์šฐ์„  CSS์—์„œ ์ œ๊ณตํ•˜๋Š” ์œ„์น˜ ๊ด€๋ จ ์†์„ฑ์€ position์ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

๊ทธ๋ฆฌ๊ณ  ์œ„์น˜๋Š” ํฌ๊ฒŒ ์ ˆ๋Œ€์œ„์น˜์™€ ์ƒ๋Œ€์œ„์น˜๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๊ทธ๋Ÿผ ํ•˜๋‚˜์”ฉ ์•Œ์•„๋ณด๋„๋ก ํ• ๊นŒ์š”? 


Relative Positioning:

์ƒ๋Œ€ ์œ„์น˜ ์„ค์ •์—์„œ ์‚ฌ์šฉ๋˜๋Š” ํ•˜์œ„ ์†์„ฑ์œผ๋กœ๋Š” top, bottom, left์™€ right๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.  

top๊ณผ left์˜ ์†์„ฑ๊ฐ’์ด ๋งˆ์ด๋„ˆ์Šค (- ) ์ˆซ์ž๋ฅผ ์‚ฌ์šฉํ•จ์œผ๋กœ์„œ bottom๊ณผ right๋ฅผ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 

  • Move Left - Use a negative value for left.
  • Move Right - Use a positive value for left.
  • Move Up - Use a negative value for top.
  • Move Down - Use a positive value for top.

NOTE: You can use bottom or right values as well in the same way as top and left.

 

๋‹ค์Œ ์˜ˆ์ œ๋ฅผ ๋ณด์‹œ์ฃ .

<div style="position:relative;left:80px;top:2px;
            background-color:yellow;">
This div has relative positioning.
</div>

This will produce following result:

This div has relative positioning.

 


Absolute Positioning:

์ ˆ๋Œ€ ํฌ์ง€์…”๋‹์€ ํŠน์ • ์œ„์น˜์— ํ•ญ์ƒ ์œ„์น˜ํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ณ ์ •์‹œํ‚ค๋Š” ๊ฒƒ์ด์ฃ .

์ƒ๋Œ€ ํฌ์ง€์…”๋‹์ฒ˜๋Ÿผ top, left, bottom, right ๋ชจ๋‘ ์‚ฌ์šฉ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ๋ฐฉ๋ฒ•๋„ ๋™์ผํ•˜์ฃ .

  • Move Left - Use a negative value for left.
  • Move Right - Use a positive value for left.
  • Move Up - Use a negative value for top.
  • Move Down - Use a positive value for top.

NOTE: You can use bottom or right values as well in the same way as top and left.

 

๋‹ค์Œ ์˜ˆ์ œ๋ฅผ ๋ณด์‹œ์ฃ .

<div style="position:absolute;left:80px;top:20px;
            background-color:yellow;">
This div has absolute positioning.
</div>

 

๊ฒฐ๊ณผ๋Š” ์ง์ ‘ ํ…Œ์ŠคํŠธํ•ด๋ณด์‹œ๊ณ  ๋ณด๋„๋ก ํ•˜์„ธ์š”. ^_^ 


Fixed Positioning:

๊ณ ์ • ํฌ์ง€์…”๋‹์€ ์ž์นซ ์ž˜๋ชป ์ดํ•ดํ•˜๋ฉด ์ ˆ๋Œ€ ํฌ์ง€์…”๋‹๊ณผ ๋™์ผํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•˜์‹ค ์ˆ˜ ์žˆ๋Š”๋ฐ ์ด ๊ณ ์ • ํฌ์ง€์…”๋‹์€ ์ƒ๋Œ€ + ์ ˆ๋Œ€ ํฌ์ง€์…”๋‹์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ๊ณ ์ • ํฌ์ง€์…”๋‹์€ ๋ˆˆ์œผ๋กœ ๋ณด์—ฌ์ง€๋Š” ํ™”๋ฉด์˜ ํŠน์ • ์œ„์น˜์— ๊ณ ์ •์‹œํ‚ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์Šคํฌ๋กค๋ง์ด ์žˆ๋”๋ผ๋„ ๋ฌด์กฐ๊ฑด ํ™”๋ฉด์˜ ํŠน์ •์œ„์น˜์— ๋ณด์ด๋„๋ก ํ•˜๋Š” ์†์„ฑ์ด์ฃ .

์—ญ์‹œ ์ƒ๋Œ€, ์ ˆ๋Œ€ ํฌ์ง€์…”๋‹์ฒ˜๋Ÿผ top, left, bottom, right ์†์„ฑ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ ์‚ฌ์šฉ๋ฐฉ๋ฒ•๋„ ๋™์ผํ•ฉ๋‹ˆ๋‹ค. 

  • Move Left - Use a negative value for left.
  • Move Right - Use a positive value for left.
  • Move Up - Use a negative value for top.
  • Move Down - Use a positive value for top.

NOTE: You can use bottom or right values as well in the same way as top and left.

 

๋‹ค์Œ ์˜ˆ์ œ๋ฅผ ๋ณด์‹œ์ฃ . 

<div style="position:fixed;left:80px;top:20px;
            background-color:yellow;">
This div has fixed positioning.
</div>

 

๊ฒฐ๊ณผ๋Š” ์ง์ ‘ ํ…Œ์ŠคํŠธํ•ด๋ณด์‹œ๊ณ  ๋ณด๋„๋ก ํ•˜์„ธ์š”. ^_^

 

 

 

 

 

 

 

Reference : http://www.tutorialspoint.com/css/css_positioning.htm