๐Ÿ„

001 header

ย 
notion imagenotion image
์ฝ”๋”ฉ์„ ๋“ค์–ด๊ฐ€๊ธฐ ์ „์— body ํƒœ๊ทธ๊ฐ€ ์•„๋‹Œ ๊ฐ€์žฅ ํฐ container๋ฅผ ๋งŒ๋“œ๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค. ๋จผ์ € section ํƒœ๊ทธ๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ฐ€์žฅ ํฐ container๋ฅผ ๋งŒ๋“ค์–ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ container๋ผ๋Š” id๋ฅผ ๊ฐ€์ง„ section์„ ์ƒ์„ฑํ•œ ๋’ค header ํƒœ๊ทธ๋ฅผ ์ถ”๊ฐ€ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
ย 
์ฝ”๋“œ์—์„œ ๊ฐ•์กฐ๋œ ๋ถ€๋ถ„์ด ์ƒˆ๋กญ๊ฒŒ ์ถ”๊ฐ€๋˜์—ˆ๋‹ค๊ณ  ๋ณด์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์•ž์œผ๋กœ๋„ ์ด๋ ‡๊ฒŒ ํ‘œ์‹œํ•˜๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
ย 
ํŒŒ์ผ๋ช… : index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="css/reset.css"> <link rel="stylesheet" href="css/style.css"> <script src="js/main.js"></script> </head> <body> <section id="container"> <header id="header"> <section class="inner"> </section> </header> </section> </body> </html>
ย 
ํŒŒ์ผ๋ช… : css/style.css
body{ background: #fafafa; } #header{ width: 100%; /* ๊ณต์ค‘์— ๋œจ๊ธฐ ์œ„ํ•จ */ position: absolute; /* ๊ฐ€์žฅ ์œ„์— ์˜ฌ๋ผ๊ฐ€ ์žˆ์–ด์•ผ ํ•˜๊ธฐ ์œ„ํ•จ */ z-index: 999; /* absolute์˜ ๊ฒฝ์šฐ ์ตœ์†Œ x์ถ•์—์„œ 1๊ฐœ y์ถ•์—์„œ 1๊ฐœ์˜ ๊ฐ’์„ ์ฃผ์–ด์•ผ ํ•จ */ left: 0; top: 0; background: white; border-bottom: 1px solid rgba(0,0,0,0.1); }
ย 
๋†’์ด ๊ฐ’์€ header๊ฐ€ ์•„๋‹Œ header ์•ˆ์˜ ์ž์‹๋“ค์—๊ฒŒ ์ฃผ๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.
ย 
ํŒŒ์ผ๋ช… : css/style.css
body{ background: #fafafa; } #header{ width: 100%; /* ๊ณต์ค‘์— ๋œจ๊ธฐ ์œ„ํ•จ */ position: absolute; /* ๊ฐ€์žฅ ์œ„์— ์˜ฌ๋ผ๊ฐ€ ์žˆ์–ด์•ผ ํ•˜๊ธฐ ์œ„ํ•จ */ z-index: 999; /* absolute์˜ ๊ฒฝ์šฐ ์ตœ์†Œ x์ถ•์—์„œ 1๊ฐœ y์ถ•์—์„œ 1๊ฐœ์˜ ๊ฐ’์„ ์ฃผ์–ด์•ผ ํ•จ */ left: 0; top: 0; background: white; border-bottom: 1px solid rgba(0,0,0,0.1); } #header .inner{ /* inner ์•ˆ์— ์ปจํ…์ธ ๋ฅผ ๋„ฃ์œผ๋ฉด ์•ˆ์— ๊ฐ’์ด ๋“ค์–ด์˜ด */ width: 975px; height: 77px; margin: 0 auto; /* ๊ฐ€์šด๋ฐ ์ •๋ ฌ */ }
ย 
๊ฒฐ๊ณผ๋ฅผ ๋ณด์‹œ๋ฉด ์•„๋ž˜์ฒ˜๋Ÿผ header์™€ inner๊ฐ€ ์ƒ๊ธด ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
notion imagenotion image
ย 
inner๊ฐ€ ์กด์žฌํ•˜๊ธฐ ๋•Œ๋ฌธ์— inner ์•ˆ์—๋งŒ ์ปจํ…์ธ ๋ฅผ ๋ฐฐ์น˜ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
inner ๋˜ํ•œ ๋กœ๊ณ  ๋ฐ•์Šค, ๊ฒ€์ƒ‰ ๋ฐ•์Šค, ์•„์ด์ฝ˜ ๋ฐ•์Šค์˜ 3๊ฐœ์˜ ๋ฐ•์Šค๋กœ ๊ตฌ๋ถ„๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.
notion imagenotion image
ย 
๋จผ์ € ๋กœ๊ณ ๋ฅผ ์ถ”๊ฐ€ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.
๋กœ๊ณ ๋Š” <h1>ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ด€๋ก€๊ฐ€ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— <h1>ํƒœ๊ทธ๋ฅผ ์„ ์–ธํ•ด์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค. ๋˜ํ•œ ๋กœ๊ณ ๋ฅผ ํด๋ฆญํ•˜๋ฉด ๋ฉ”์ธ ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•˜๊ธฐ ๋•Œ๋ฌธ์— <a>๋ฅผ ํƒœ๊ทธ๋ฅผ ํ†ตํ•ด์„œ index.html๋กœ ๋Œ์•„์˜ฌ ์ˆ˜ ์žˆ๋„๋ก ํ•˜์˜€์Šต๋‹ˆ๋‹ค.
ย 
ํŒŒ์ผ๋ช… : index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="css/reset.css"> <link rel="stylesheet" href="css/style.css"> <script src="js/main.js"></script> </head> <body> <section id="container"> <header id="header"> <section class="inner"> <h1 class="logo"> <a herf="index.html"> </a> </h1> </section> </header> </section> </body> </html>
ย 
์•„์ด์ฝ˜์„ ๋„ฃ์„ ๋•Œ ์ด๋ฏธ์ง€๋ฅผ ํ†ตํ•ด์„œ ๋„ฃ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ €ํฌ๋Š” background๋ฅผ ํ™œ์šฉํ•ด์„œ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ์•„์ด์ฝ˜์„ ๋ฐฐ์น˜ํ•ด ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
ย 
๋จผ์ €, ๋กœ๊ณ ์— ์“ธ ์ด๋ฏธ์ง€๊ฐ€ ๋“ค์–ด์žˆ๋Š” ์ œ๊ณต๋œ imgs ํŒŒ์ผ์„ ์••์ถ•ํ•ด์ œํ•˜์—ฌ insta_clone ํด๋”์— ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
notion imagenotion image
ย 
ํด๋” ์•ˆ์— background ์ด๋ฏธ์ง€๋ฅผ SpriteCow๋กœ ํ™œ์šฉํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค.
notion imagenotion image
ย 
notion imagenotion image
ย 
๊ฒ€์ƒ‰ ์ฐฝ์— SpriteCow๋ฅผ ๊ฒ€์ƒ‰ํ•ด์„œ www.spritecow.com ์‚ฌ์ดํŠธ์— ์ ‘์†ํ•ฉ๋‹ˆ๋‹ค. ์‚ฌ์ดํŠธ์— OpenImage๋ฅผ ํด๋ฆญํ•˜๊ณ  ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์ด๋ฏธ์ง€๋ฅผ ์—ฝ๋‹ˆ๋‹ค.
notion imagenotion image
ย 
๊ทธ๋Ÿฌ๋ฉด ์•„๋ž˜์™€ ๊ฐ™์€ ์ฐฝ์ด ๋‚˜ํƒ€๋‚˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
ย 
notion imagenotion image
ย 
์—ฌ๊ธฐ์„œ ๋‚ด๊ฐ€ ์›ํ•˜๋Š” ์ด๋ฏธ์ง€์„ ์„ ํƒํ•˜๊ฒŒ ๋˜๋ฉด ์•„๋ž˜ ๊ทธ๋ฆผ๊ณผ ๊ฐ™์ด ์ด์— ๋Œ€ํ•œ ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์ด๋ฏธ์ง€์™€ ๊ฒฝ๋กœ, ๋†’์ด์™€ ๋„ˆ๋น„๋ฅผ ๋ณด์—ฌ์ฃผ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์ด๋ฏธ์ง€๋Š” ๊ณต๊ฐ„์„ ์ฐจ์ง€ํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ๋†’์ด์™€ ๋„ˆ๋น„๋ฅผ ํ•ญ์ƒ ์ง€์ •ํ•ด ์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
notion imagenotion image
์•„๋ž˜์˜ ์ฝ”๋“œ๋ฅผ ๋ณต์‚ฌํ•˜์—ฌ css/style.css ํŒŒ์ผ์— ์ถ”๊ฐ€ํ•ด์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์ด์ฒ˜๋Ÿผ ๋ชจ๋“  ์•„์ด์ฝ˜์„ ๊ฐ€์ ธ์˜จ CSS ์†Œ์Šค์ฝ”๋“œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.
ย 
ํŒŒ์ผ๋ช… : css/style.css
.sprite_insta_icon{ display: inline-block; background: url('../imgs/background01.png') no-repeat -53px -235px; width: 22px; height: 22px; } .sprite_write_logo{ display: inline-block; background: url('../imgs/background01.png') no-repeat -94px -72px; width: 103px; height: 29px; } .sprite_compass_icon{ display: inline-block; background: url('../imgs/background01.png') no-repeat -130px -286px; width: 23px; height: 23px; } .sprite_user_icon_outline{ display: inline-block; background: url('../imgs/background01.png') no-repeat -272px -182px; width: 22px; height: 24px; } .sprite_heart_icon_outline{ display: inline-block; background: url('../imgs/background01.png') no-repeat -52px -261px; width: 24px; height: 22px; } .sprite_small_search_icon{ display: inline-block; background: url('../imgs/background01.png') no-repeat -337px -246px; width: 10px; height: 10px; } .sprite_more_icon{ display: inline-block; background: url('../imgs/background01.png') no-repeat -301px -218px; width: 15px; height: 3px; } .sprite_bubble_icon{ display: inline-block; background: url('../imgs/background01.png') no-repeat -239px -202px; width: 24px; height: 24px; } .sprite_share_icon{ display: inline-block; background: url('../imgs/background01.png') no-repeat -324px -52px; width: 21px; height: 24px; } .sprite_bookmark_outline{ display: inline-block; background: url('../imgs/background01.png') no-repeat -237px -286px; width: 19px; height: 24px; } .sprite_bookmark_outline.on{ background: url('../imgs/background01.png') no-repeat -159px -286px; width: 19px; height: 24px; } .sprite_small_heart_icon_outline{ display: inline-block; background: url('../imgs/background01.png') no-repeat -323px -274px; width: 12px; height: 11px; } .sprite_camera_icon{ display: inline-block; background: url('../imgs/background01.png') no-repeat -271px -104px; width: 24px; height: 22px; } .sprite_insta_big_logo{ display: inline-block; background: url('../imgs/background02.png') no-repeat -98px -150px; width: 175px; height: 51px; } .sprite_plus_icon{ display: inline-block; background: url('../imgs/background01.png') no-repeat -187px -202px; width: 23px; height: 23px; } body{ background: #fafafa; } ...
ย 
CSS ์ฝ”๋“œ์— display: inline-block; ์„ ๋‹ค ๊น”์•„์ค€ ์ด์œ ๋Š” ๋„ˆ๋น„์™€ ๋†’์ด๊ฐ’์„ ์ž…๋ ฅํ•˜๋ ค๋ฉด block element์—๊ฒŒ๋งŒ ์ž…๋ ฅ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ๊ฐ„ํ˜น๊ฐ€๋‹ค๊ฐ€ ์•„์ด์ฝ˜์„ ์ž…๋ ฅํ• ๋•Œ ์ธ๋ผ์ธ ์š”์†Œ๋ฅผ ์‚ฌ์šฉ๋˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์ƒ๊น๋‹ˆ๋‹ค. ์ธ๋ผ์ธ ์š”์†Œ์—๋‹ค๊ฐ€ ์•„์ด์ฝ˜ ์ž…๋ ฅํ•˜๊ฒŒ ๋˜๋ฉด ์ธ๋ผ์ธ ์š”์†Œ์ด๊ธฐ ๋•Œ๋ฌธ์— ํ˜•ํƒœ๋ฅผ ๊ฐ€์งˆ ์ˆ˜ ์—†๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ class์— ์ž…๋ ฅํ•˜๋Š” ๋ชจ๋“  display ์†์„ฑ์„ ์ธ๋ผ์ธ ์†์„ฑ๊ณผ ๋ธ”๋ก ์†์„ฑ์„ ํ•จ๊ป˜ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋„๋ก ๋งŒ๋“  ๊ฒƒ ์ž…๋‹ˆ๋‹ค.
ย 
์ด๋ ‡๊ฒŒ ์•„์ด์ฝ˜๋“ค์„ ๊ฐ€์ง€๊ณ  ์™”์œผ๋ฉด header ๋ถ€๋ถ„์— ์•„์ด์ฝ˜์„ ์ถ”๊ฐ€ํ•ด ๋ด…์‹œ๋‹ค.
ย 
ํŒŒ์ผ๋ช… : index.html
... <header id="header"> <section class="inner"> <h1 class="logo"> <a herf="index.html"> <div class="sprite_insta_icon"></div> <div class="sprite_write_logo"></div> </a> </h1> </section> </header> ...
ย 
๊ฒฐ๊ณผ๋ฅผ ๋ณด์‹œ๋ฉด ๋กœ๊ณ ๋“ค ์‚ฌ์ด์— ์ž‘์€ ๊ธ€์ž๊ฐ€ ์ƒ๊ธฐ๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Š” <a>ํƒœ๊ทธ๋กœ ์ธํ•˜์—ฌ ์ƒ๊ธฐ๋Š” ๊ฒƒ์œผ๋กœ <a>ํƒœ๊ทธ์˜ ๋ฐฐ๊ฒฝ์ƒ‰์„ ์—†์• ์ฃผ๋ฉด ํ•ด๊ฒฐ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.
notion imagenotion image
ย 
ํŒŒ์ผ๋ช… : css/style.css
... #header .inner{ /* inner ์•ˆ์— ์ปจํ…์ธ ๋ฅผ ๋„ฃ์œผ๋ฉด ์•ˆ์— ๊ฐ’์ด ๋“ค์–ด์˜ด */ width: 975px; height: 77px; margin: 0 auto; /* ๊ฐ€์šด๋ฐ ์ •๋ ฌ */ } #header .inner .logo > a{ color: transparent; /* ๋ฐฐ๊ฒฝ์ƒ‰์„ ํˆฌ๋ช…ํ•˜๊ฒŒ ๋งŒ๋“ฌ */ }
ย 
notion imagenotion image
ย 
๋˜ํ•œ ์•„์ด์ฝ˜๋“ค์„ ์ผ์ง์„  ์ƒ์— ์œ„์น˜ํ•˜๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” vertical-align ๊ฐ’์„ middle๋กœ ์ฃผ๋ฉด ํ•ด๊ฒฐ์ด ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.
ย 
ํŒŒ์ผ๋ช… : css/style.css
... #header .inner .logo > a{ color: transparent; /* ๋ฐฐ๊ฒฝ์ƒ‰์„ ํˆฌ๋ช…ํ•˜๊ฒŒ ๋งŒ๋“ฌ */ } #header .inner .logo div{ vertical-align: middle; }
ย 
notion imagenotion image
ย 
๋‘ ๋กœ๊ณ ๊ฐ€ ๊ฐ€๋กœ๋กœ ์ •๋ ฌ๋ฐ›๋Š” ์ด์œ ๋Š” display: inline-block; ์†์„ฑ์„ ์ฃผ์—ˆ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ์›๋ž˜ ๋ธ”๋ก ์š”์†Œ๋Š” ํ™”๋ฉด์— ๋ฐฐ์น˜์‹œํ‚ค๋ฉด ์„ธ๋กœ ๋ฐฐ์น˜ ๋ฐ›๋Š” ๊ฒƒ์ด ๊ธฐ๋ณธ์ž…๋‹ˆ๋‹ค. ์„ธ๋กœ ๋ฐฐ์น˜๋ฅผ ๋ฐ›๋Š” ๋ธ”๋ก ์š”์†Œ๋ฅผ ๊ฐ€๋กœ ๋ฐฐ์น˜ ์‹œํ‚ค๊ธฐ ์œ„ํ•œ float(ํ”Œ๋กฏ), inline-block ๋ฐฉ๋ฒ•์ด ์žˆ์Šต๋‹ˆ๋‹ค.
ย 
๋‹ค์Œ์—๋Š” ๋กœ๊ณ  ์‚ฌ์ด์˜ ๋ฐ”(๋ง‰๋Œ€)๋ฅผ ๋งŒ๋“ค์–ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
notion imagenotion image
ย 
๋ฐ”๋ฅผ ๋งŒ๋“œ์‹ค ๋•Œ ์ด๋ฏธ์ง€๋ฅผ ํ™œ์šฉํ•˜์‹œ๋Š” ๋ถ„๋“ค๋„ ๋งŽ์ด ๊ณ„์‹ ๋ฐ, ๊ฐ€์ƒ ์„ ํƒ์ž๋ฅผ ํ™œ์šฉํ•˜๋Š” ๊ฒƒ์ด ์กฐ๊ธˆ ๋” ํŽธ๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ €ํฌ๋Š” ๊ฐ€์ƒ ์„ ํƒ์ž๋ฅผ ํ™œ์šฉํ•ด์„œ ๋ฐ”๋ฅผ ๋งŒ๋“ค์–ด ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
ย 
CSS ์„ ํƒ์ž ๋’ค์— ์ฝœ๋ก (:)์„ ๋„ฃ๊ฒŒ ๋˜๋ฉด ๊ฐ€์ƒ ์„ ํƒ์ž๊ฐ€ ๋ฉ๋‹ˆ๋‹ค. ๋ง ๊ทธ๋Œ€๋กœ ๊ฐ€์ƒ์œผ๋กœ ์„ ํƒํ•ด์ฃผ๊ฒ ๋‹ค๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. after๋Š” ์„ ํƒํ•œ ํ›„์— ๋ฌด์–ธ๊ฐ€๋ฅผ ๋งŒ๋“ค์–ด ์ฃผ๊ฒ ๋‹ค๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. after๋Š” ๊ผญ content๋ผ๋Š” ๊ณต๋ฐฑ์„ ๋ฐ›์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค.
ย 
ํŒŒ์ผ๋ช… : css/style.css
... #header .inner .logo div{ vertical-align: middle; } #header .inner .logo .sprite_insta_icon{ position: relative; /* after์—๊ฒŒ ์œ„์น˜ ๊ธฐ์ค€์„ ์ „๋‹ฌํ•ด์ฃผ๊ธฐ ์œ„ํ•จ */ margin-right: 30px; } #header .inner .logo .sprite_insta_icon:after{ content: ''; /* ๊ณต๋ฐฑ์„ ๋ฐ›์•„์˜ด */ width: 1px; height: 28px; background: #000; position: absolute; /* ๋ถ€๋ชจ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์œ„์น˜๋ฅผ ์žก์Œ */ right: -15px; top: 0; }
ย 
notion imagenotion image
ย 
๋‹ค์Œ์œผ๋กœ ๊ฒ€์ƒ‰ ์ฐฝ๊ณผ ์˜ค๋ฅธ์ชฝ์˜ ์•„์ด์ฝ˜๋“ค์„ ์ถ”๊ฐ€ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.
๊ฒ€์ƒ‰ ์ฐฝ ์œ„์— ๊ธ€์ž๋“ค์ด ํฌ์ปค์Šค ๋˜๋Š” ์ˆœ๊ฐ„ ์‚ฌ๋ผ์ง€๊ณ  ์˜†์œผ๋กœ ๊ฐ€๋Š” fake_field ๊ธฐ๋Šฅ๊ณผ 4๊ฐœ์˜ ์•„์ด์ฝ˜๋“ค๋„ ๋งŒ๋“ค์–ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
notion imagenotion image
notion imagenotion image
ย 
notion imagenotion image
ย 
ํŒŒ์ผ๋ช… : index.html
... <header id="header"> <section class="inner"> <h1 class="logo"> <a herf="index.html"> <div class="sprite_insta_icon"></div> <div class="sprite_write_logo"></div> </a> </h1> <div class="search_box"> <input type="text" placeholder="๊ฒ€์ƒ‰" id="search-field"> <div class="fake_field"> <span class="sprite_small_search_icon"></span> <span>๊ฒ€์ƒ‰</span> </div> </div> <div class="right_icons"> <div class="sprite_camera_icon"></div> <div class="sprite_compass_icon"></div> <div class="sprite_heart_icon_outline"></div> <div class="sprite_user_icon_outline"></div> </div> </section> </header> ...
ย 
๊ฒฐ๊ณผ๋ฅผ ๋ณด์‹œ๋ฉด ์„ธ๋กœ๋กœ ๋ฐฐ์น˜๋œ ๊ฒƒ์„ ๋ณด์—ฌ์ฃผ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ๊ฐ€๋กœ๋กœ ๋ฐฐ์น˜์‹œํ‚ค๊ธฐ ์œ„ํ•ด์„œ display: flex ์†์„ฑ์„ ์‚ฌ์šฉํ•˜๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. flex๋Š” ์ •๋ ฌํ•˜๊ณ ์ž ํ•˜๋Š” ๋Œ€์ƒ์ด ์•„๋‹Œ ์ •๋ ฌํ•˜๊ณ ์ž ํ•˜๋Š” ๋Œ€์ƒ์˜ ๋ถ€๋ชจ์—๊ฒŒ ์ฃผ๋Š” ์†์„ฑ์ž…๋‹ˆ๋‹ค.
notion imagenotion image
ย 
ํŒŒ์ผ๋ช… : css/style.css
... #header .inner{ /* inner ์•ˆ์— ์ปจํ…์ธ ๋ฅผ ๋„ฃ์œผ๋ฉด ์•ˆ์— ๊ฐ’์ด ๋“ค์–ด์˜ด */ width: 975px; height: 77px; margin: 0 auto; /* ๊ฐ€์šด๋ฐ ์ •๋ ฌ */ display: flex; /* ๊ฐ€๋กœ ๋ฐฐ์น˜ */ justify-content: space-between; /* x์ถ• ์ •๋ ฌ_๊ณต๊ฐ„์„ ์ž๋™์œผ๋กœ ๋ถ„๋ฐฐํ•จ */ align-items: center; /* y์ถ• ์ •๋ ฌ */ } ...
ย 
notion imagenotion image
ย 
๊ฒฐ๊ณผ๋ฅผ ๋ณด๋ฉด ์ž˜ ์ •๋ ฌ์ด ๋œ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฒ€์ƒ‰ ์ฐฝ ๋ถ€๋ถ„๊ณผ ์•„์ด์ฝ˜ ๋งˆ์ง„ ๋ถ€๋ถ„์„ ์ข€ ๋” ์ˆ˜์ •ํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.
ย 
ํŒŒ์ผ๋ช… : css/style.css
... #header .inner .logo .sprite_insta_icon{ position: relative; /* after์—๊ฒŒ ์œ„์น˜ ๊ธฐ์ค€์„ ์ „๋‹ฌํ•ด์ฃผ๊ธฐ ์œ„ํ•จ */ margin-right: 30px; } #header .inner .logo .sprite_insta_icon:after{ content: ''; /* ๊ณต๋ฐฑ์„ ๋ฐ›์•„์˜ด */ width: 1px; height: 28px; background: #000; position: absolute; /* ๋ถ€๋ชจ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์œ„์น˜๋ฅผ ์žก์Œ */ right: -15px; top: 0; } #header .search_box{ position: relative; /* ๊ธฐ์ค€์ ์„ ์žก๊ณ  ๊ฐ€๋กœ ๋ฐฐ์น˜ */ } #search-field{ width: 185px; height: 28px; background: #fafafa; border: 1px solid #dbdbdb; border-radius: 3px; padding: 3px 30px; /* ์œ„์•„๋ž˜ ์–‘์ชฝ */ color: #999; font-weight: 400; text-align: left; /* ๊ธ€์ž ์ž…๋ ฅ ์‹œ ์™ผ์ชฝ๋ถ€ํ„ฐ ๋ณด์ด๋„๋ก ํ•˜๊ธฐ ์œ„ํ•จ */ font-size: 14px; outline: none; /* ํฌ์ปค์Šค ํ–ˆ์„ ๋•Œ ๋‚˜ํƒ€๋‚˜๋Š” ํŒŒ๋ž€์„  */ } #search-field::placeholder{ /* ์ฝœ๋ก 2๊ฐœ(::) - ์†์„ฑ์„ ํƒ์ž */ font-size: 0; /* ํฌ์ปค์Šค๊ฐ€ ๋˜์ง€ ์•Š์„ ๋•Œ ๊ฒ€์ƒ‰ ๊ธ€์ž๊ฐ€ ๋ณด์ด์ง€ ์•Š๋„๋ก ํ•˜๊ธฐ ์œ„ํ•จ */ } #search-field:focus::placeholder{ font-size: 14px; /* ํฌ์ปค์Šค ๋˜์—ˆ์„ ๋•Œ ๊ฒ€์ƒ‰ ๊ธ€์ž๊ฐ€ ๋ณด์ด๋„๋ก ํ•œ๋‹ค */ } #header .search_box .fake_field{ position: absolute; /* ๊ฒ€์ƒ‰ ์ฐฝ ์œ„์— ๊ธ€์ž๋ฅผ ๋ณด์ด๊ธฐ ์œ„ํ•จ */ /* ๊ฐ€์šด๋ฐ ๋ฐฐ์น˜ํ•˜๋Š” ๊ณต์‹ */ left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: none; /* ๊ฒ€์ƒ‰์„ ๋ˆŒ๋ €์„ ๋•Œ์—๋Š” ํฌ์ธํ„ฐ ์ธ์‹์ด ์•ˆ ๋จ */ } /* ๋ฌผ๊ฒฐ(~) - ๊ทผ์ฒ˜์— ์žˆ๋Š” fake_field */ #search-field:focus~.fake_field > span:nth-child(1){ transform: translateX(-105px); /* ๋‹๋ณด๊ธฐ๋ฅผ ์™ผ์ชฝ์œผ๋กœ ์ด๋™ */ } #search-field:focus~.fake_field > span:nth-child(2){ display: none; /* ํฌ์ปค์Šค ๋˜์—ˆ์„ ๋•Œ ๊ธ€์ž ์ˆจ๊ธฐ๊ธฐ */ } #header .right_icons{ width: 132px; /* ๋ถ€๋ชจ๊ฐ’ ์ขŒ์šฐ๊ฐ’ ๊ณ ์ • */ display: flex; justify-content: space-between; /* x์ถ• ์ •๋ ฌ_๊ณต๊ฐ„์„ ์ž๋™์œผ๋กœ ๋ถ„๋ฐฐํ•จ */ }
ย 
์ด๋ ‡๊ฒŒ ํ•ด์„œ header๋ถ€๋ถ„์ด ์™„๋ฃŒ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋งˆ์ง€๋ง‰์œผ๋กœ ๋””ํ…Œ์ผ์„ ๋‹ค๋“ฌ์–ด ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
notion imagenotion image
๋ง‰๋Œ€ ๋ฐ”๋ฅผ ์œ„๋กœ ์‚ด์ง ์˜ฌ๋ฆฌ๊ณ  instagram ๋กœ๊ณ ๋Š” ์•„๋ž˜๋กœ ์‚ด์ง ๋‚ด๋ฆฌ๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
ย 
ํŒŒ์ผ๋ช… : css/style.css
... #header .inner .logo div{ vertical-align: middle; } #header .inner .logo div:nth-child(2){ transform: translateY(2px); } #header .inner .logo .sprite_insta_icon{ position: relative; /* after์—๊ฒŒ ์œ„์น˜ ๊ธฐ์ค€์„ ์ „๋‹ฌํ•ด์ฃผ๊ธฐ ์œ„ํ•จ */ margin-right: 30px; } #header .inner .logo .sprite_insta_icon:after{ content: ''; /* ๊ณต๋ฐฑ์„ ๋ฐ›์•„์˜ด */ width: 1px; height: 28px; background: #000; position: absolute; /* ๋ถ€๋ชจ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์œ„์น˜๋ฅผ ์žก์Œ */ right: -15px; top: -4px; } ...
ย 
์ด๋ ‡๊ฒŒ ์›น ํŽ˜์ด์ง€๋ฅผ ๋งŒ๋“ค ๋•Œ์—๋Š” ํฐ ํ‹€์„ ๋ณด๊ณ  ์ ์ฐจ์ ์œผ๋กœ ์ž‘์€ ์˜์—ญ๋“ค์„ ์‚ดํŽด๋ณด๋ฉด์„œ ์ฝ”๋”ฉํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•˜๋‹ค๊ณ  ์•Œ๊ณ  ๋„˜์–ด๊ฐ€์‹œ๋ฉด ๋  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.
notion imagenotion image
ย 
์™„์„ฑ๋œ ์ฝ”๋“œ๋Š” ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.
ย 
ํŒŒ์ผ๋ช… : index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="css/reset.css"> <link rel="stylesheet" href="css/style.css"> <script src="js/main.js"></script> </head> <body> <section id="container"> <header id="header"> <section class="inner"> <h1 class="logo"> <a herf="index.html"> <div class="sprite_insta_icon"></div> <div class="sprite_write_logo"></div> </a> </h1> <div class="search_box"> <input type="text" placeholder="๊ฒ€์ƒ‰" id="search-field"> <div class="fake_field"> <span class="sprite_small_search_icon"></span> <span>๊ฒ€์ƒ‰</span> </div> </div> <div class="right_icons"> <div class="sprite_camera_icon"></div> <div class="sprite_compass_icon"></div> <div class="sprite_heart_icon_outline"></div> <div class="sprite_user_icon_outline"></div> </div> </section> </header> </section> </body> </html>
ย 
ํŒŒ์ผ๋ช… : css/style.css
.sprite_insta_icon{ display: inline-block; background: url('../imgs/background01.png') no-repeat -53px -235px; width: 22px; height: 22px; } .sprite_write_logo{ display: inline-block; background: url('../imgs/background01.png') no-repeat -94px -72px; width: 103px; height: 29px; } .sprite_compass_icon{ display: inline-block; background: url('../imgs/background01.png') no-repeat -130px -286px; width: 23px; height: 23px; } .sprite_user_icon_outline{ display: inline-block; background: url('../imgs/background01.png') no-repeat -272px -182px; width: 22px; height: 24px; } .sprite_heart_icon_outline{ display: inline-block; background: url('../imgs/background01.png') no-repeat -52px -261px; width: 24px; height: 22px; } .sprite_small_search_icon{ display: inline-block; background: url('../imgs/background01.png') no-repeat -337px -246px; width: 10px; height: 10px; } .sprite_more_icon{ display: inline-block; background: url('../imgs/background01.png') no-repeat -301px -218px; width: 15px; height: 3px; } .sprite_bubble_icon{ display: inline-block; background: url('../imgs/background01.png') no-repeat -239px -202px; width: 24px; height: 24px; } .sprite_share_icon{ display: inline-block; background: url('../imgs/background01.png') no-repeat -324px -52px; width: 21px; height: 24px; } .sprite_bookmark_outline{ display: inline-block; background: url('../imgs/background01.png') no-repeat -237px -286px; width: 19px; height: 24px; } .sprite_bookmark_outline.on{ background: url('../imgs/background01.png') no-repeat -159px -286px; width: 19px; height: 24px; } .sprite_small_heart_icon_outline{ display: inline-block; background: url('../imgs/background01.png') no-repeat -323px -274px; width: 12px; height: 11px; } .sprite_camera_icon{ display: inline-block; background: url('../imgs/background01.png') no-repeat -271px -104px; width: 24px; height: 22px; } .sprite_insta_big_logo{ display: inline-block; background: url('../imgs/background02.png') no-repeat -98px -150px; width: 175px; height: 51px; } .sprite_plus_icon{ display: inline-block; background: url('../imgs/background01.png') no-repeat -187px -202px; width: 23px; height: 23px; } body{ background:#fafafa; } #header{ width: 100%; /* ๊ณต์ค‘์— ๋œจ๊ธฐ ์œ„ํ•จ */ position: absolute; /* ๊ฐ€์žฅ ์œ„์— ์˜ฌ๋ผ๊ฐ€ ์žˆ์–ด์•ผ ํ•˜๊ธฐ ์œ„ํ•จ */ z-index: 999; /* absolute์˜ ๊ฒฝ์šฐ ์ตœ์†Œ x์ถ•์—์„œ 1๊ฐœ y์ถ•์—์„œ 1๊ฐœ์˜ ๊ฐ’์„ ์ฃผ์–ด์•ผ ํ•จ */ left: 0; top: 0; background: white; border-bottom: 1px solid rgba(0,0,0,0.1); } #header .inner{ /* inner ์•ˆ์— ์ปจํ…์ธ ๋ฅผ ๋„ฃ์œผ๋ฉด ์•ˆ์— ๊ฐ’์ด ๋“ค์–ด์˜ด */ width: 975px; height: 77px; margin: 0 auto; /* ๊ฐ€์šด๋ฐ ์ •๋ ฌ */ display: flex; /* ๊ฐ€๋กœ ๋ฐฐ์น˜ */ justify-content: space-between; /* x์ถ• ์ •๋ ฌ_๊ณต๊ฐ„์„ ์ž๋™์œผ๋กœ ๋ถ„๋ฐฐํ•จ */ align-items: center; /* y์ถ• ์ •๋ ฌ */ } #header .inner .logo > a{ color: transparent; /* ๋ฐฐ๊ฒฝ์ƒ‰์„ ํˆฌ๋ช…ํ•˜๊ฒŒ ๋งŒ๋“ฌ */ } #header .inner .logo div{ vertical-align: middle; } #header .inner .logo .sprite_insta_icon{ position: relative; /* after์—๊ฒŒ ์œ„์น˜ ๊ธฐ์ค€์„ ์ „๋‹ฌํ•ด์ฃผ๊ธฐ ์œ„ํ•จ */ margin-right: 30px; } #header .inner .logo .sprite_insta_icon:after{ content: ''; /* ๊ณต๋ฐฑ์„ ๋ฐ›์•„์˜ด */ width: 1px; height: 28px; background: #000; position: absolute; /* ๋ถ€๋ชจ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์œ„์น˜๋ฅผ ์žก์Œ */ right: -15px; top: -4px; } #header .search_box{ position: relative; /* ๊ธฐ์ค€์ ์„ ์žก๊ณ  ๊ฐ€๋กœ ๋ฐฐ์น˜ */ } #search-field{ width: 185px; height: 28px; background: #fafafa; border: 1px solid #dbdbdb; border-radius: 3px; padding: 3px 30px; /* ์œ„์•„๋ž˜ ์–‘์ชฝ */ color: #999; font-weight: 400; text-align: left; /* ๊ธ€์ž ์ž…๋ ฅ ์‹œ ์™ผ์ชฝ๋ถ€ํ„ฐ ๋ณด์ด๋„๋ก ํ•˜๊ธฐ ์œ„ํ•จ */ font-size: 14px; outline: none; /* ํฌ์ปค์Šค ํ–ˆ์„ ๋•Œ ๋‚˜ํƒ€๋‚˜๋Š” ํŒŒ๋ž€์„  */ } #search-field::placeholder{ /* ์ฝœ๋ก 2๊ฐœ(::) - ์†์„ฑ์„ ํƒ์ž */ font-size: 0; /* ํฌ์ปค์Šค๊ฐ€ ๋˜์ง€ ์•Š์„ ๋•Œ ๊ฒ€์ƒ‰ ๊ธ€์ž๊ฐ€ ๋ณด์ด์ง€ ์•Š๋„๋ก ํ•˜๊ธฐ ์œ„ํ•จ */ } #search-field:focus::placeholder{ font-size: 14px; /* ํฌ์ปค์Šค ๋˜์—ˆ์„ ๋•Œ ๊ฒ€์ƒ‰ ๊ธ€์ž๊ฐ€ ๋ณด์ด๋„๋ก ํ•œ๋‹ค */ } #header .search_box .fake_field{ position: absolute; /* ๊ฒ€์ƒ‰ ์ฐฝ ์œ„์— ๊ธ€์ž๋ฅผ ๋ณด์ด๊ธฐ ์œ„ํ•จ */ /* ๊ฐ€์šด๋ฐ ๋ฐฐ์น˜ํ•˜๋Š” ๊ณต์‹ */ left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: none; /* ๊ฒ€์ƒ‰์„ ๋ˆŒ๋ €์„ ๋•Œ์—๋Š” ํฌ์ธํ„ฐ ์ธ์‹์ด ์•ˆ ๋จ */ } /* ๋ฌผ๊ฒฐ(~) - ๊ทผ์ฒ˜์— ์žˆ๋Š” fake_field */ #search-field:focus~.fake_field > span:nth-child(1){ transform: translateX(-105px); /* ๋‹๋ณด๊ธฐ๋ฅผ ์™ผ์ชฝ์œผ๋กœ ์ด๋™ */ } #search-field:focus~.fake_field > span:nth-child(2){ display: none; /* ํฌ์ปค์Šค ๋˜์—ˆ์„ ๋•Œ ๊ธ€์ž ์ˆจ๊ธฐ๊ธฐ */ } #header .right_icons{ width: 132px; /* ๋ถ€๋ชจ๊ฐ’ ์ขŒ์šฐ๊ฐ’ ๊ณ ์ • */ display: flex; justify-content: space-between; /* x์ถ• ์ •๋ ฌ_๊ณต๊ฐ„์„ ์ž๋™์œผ๋กœ ๋ถ„๋ฐฐํ•จ */ } #header .inner .logo div:nth-child(2){ transform: translateY(2px); } #header .inner .logo .sprite_insta_icon{ position: relative; /* after์—๊ฒŒ ์œ„์น˜ ๊ธฐ์ค€์„ ์ „๋‹ฌํ•ด์ฃผ๊ธฐ ์œ„ํ•จ */ margin-right: 30px; }
ย