๐Ÿ„

006 event

ย 
๊ฒŒ์‹œ๋ฌผ์— ์žˆ๋Š” ํ•˜ํŠธ๋ฅผ ๋ˆ„๋ฅด๋ฉด ํ•˜ํŠธ์— ๋ถˆ์ด ๋“ค์–ด์˜ค๋Š” ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
๋จผ์ € main.js์˜ ์œ„์น˜๋ฅผ body ๊ฐ€์žฅ ๋ฐ‘์œผ๋กœ ์˜ฎ๊ฒจ ์ค๋‹ˆ๋‹ค. ๊ฐ€์žฅ ์œ„์— ์žˆ์„ ๊ฒฝ์šฐ ์›น ํŽ˜์ด์ง€๊ฐ€ ๋กœ๋“œ๋˜๊ธฐ ์ „์— ์ฝ”๋“œ๊ฐ€ ์‹คํ–‰๋˜์–ด ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
ย 
JS๋ฅผ ์œ„์— ๋†“๊ณ  ์‚ฌ์šฉํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. JS์— ๊ธฐ๋‹ค๋ฆฌ๋ผ๋Š” ๋ช…๋ น์–ด๋ฅผ ์ฃผ์–ด ์‚ฌ์šฉํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. HTML๋ฌธ์„œ๊ฐ€ ๋กœ๋“œ๋  ๋•Œ๊นŒ์ง€ ๊ธฐ๋‹ค๋ ธ๋‹ค๊ฐ€ ์‹คํ–‰ํ•˜๋ผ๋Š” ๋œป์„ ๊ฐ–๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.
ย 
ํŒŒ์ผ๋ช… : js/main.js
window.addEventListener('DOMContentLoaded',function(){ });
ย 
์ €ํฌ๋Š” body ์•ž ๋ถ€๋ถ„์— ๋„ฃ๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
ย 
ํŒŒ์ผ๋ช… : index.html
... <script src="js/main.js"></script> </body> </html>
ย 
๋จผ์ € ์ž˜ ํด๋ฆญ๋˜๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•˜์—ฌ ์ฝ˜์†” ์ฐฝ์— ๋ฉ”์‹œ์ง€๋ฅผ ๋„์›Œ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
ย 
ํŒŒ์ผ๋ช… : js/main.js
const heart = document.querySelector( '.heart_btn'); // ํ•˜ํŠธ ์š”์†Œ ๋ถ€๋ถ„์„ ์„ ํƒํ•ด์„œ ๊ฐ€์ ธ์˜ด heart.addEventListener('click', function(){ console.log('hit'); // heart.classList.toggle('on'); // ํ•˜ํŠธ๋ฅผ ํด๋ฆญํ•˜๋ฉด .on ํด๋ž˜์Šค๋ฅผ ์ถ”๊ฐ€ });
ย 
notion imagenotion image
ย 
ํŒŒ์ผ๋ช… : js/main.js
const heart = document.querySelector( '.heart_btn'); // ํ•˜ํŠธ ์š”์†Œ ๋ถ€๋ถ„์„ ์„ ํƒํ•ด์„œ ๊ฐ€์ ธ์˜ด heart.addEventListener('click', function(){ console.log('hit'); heart.classList.toggle('on'); // ํ•˜ํŠธ๋ฅผ ํด๋ฆญํ•˜๋ฉด .on ํด๋ž˜์Šค๋ฅผ ์ถ”๊ฐ€ });
ย 
ํŒŒ์ผ๋ช…: css/style.css
... .contents .bottom_icons .left_icons > div{ margin-right: 10px; } .heart_btn.on .sprite_heart_icon_outline{ /* on ํด๋ž˜์Šค๊ฐ€ ์ถ”๊ฐ€ ๋œ ๊ฒฝ์šฐ ์ด๋ฏธ์ง€๋ฅผ ๋ณ€๊ฒฝ */ background: url('../imgs/background01.png') no-repeat -26px -261px; } .contents .likes{ padding: 5px 20px; color: #262626; } ...
ย 
ํ•˜ํŠธ๋ฅผ ๋ˆ„๋ฅผ๋•Œ๋งˆ๋‹ค ์ƒ‰์ด ๋ณ€ํ•˜๋Š” ๊ฒƒ์„ ๋ณด์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
notion imagenotion image
notion imagenotion image
ย 
ํ•˜์ง€๋งŒ ๋‹ค์Œ ๊ฒŒ์‹œ๋ฌผ์ด ํ•˜ํŠธ๋Š” ์‹คํ–‰์ด ์•ˆ๋˜๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. querySelector()๋Š” ํ•˜๋‚˜๋งŒ ๊ฐ€์ง€๊ณ  ์˜ค๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ๊ทธ๋ ‡๋‹ค๊ณ  querySelectorAll()์„ ์‚ฌ์šฉํ•˜๊ฒŒ ๋˜๋ฉด ๋ฐฐ์—ด๋กœ ๋“ค์–ด์˜ค๊ธฐ ๋•Œ๋ฌธ์— ํ•˜๋‚˜ํ•˜๋‚˜ ์ด๋ฒคํŠธ๋ฅผ ๋„ฃ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ๋Š” event delegation์„ ์‚ฌ์šฉํ•˜๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
ย 
์ด๋ฒˆ์—๋Š” ์Šคํฌ๋กค ์ด๋ฒคํŠธ๋ฅผ ์ถ”๊ฐ€ํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
์Šคํฌ๋กค์„ ํ•  ๋•Œ ๋งˆ๋‹ค ์ˆซ์ž๊ฐ€ ๋ฐ”๋€Œ๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๊ฐ€ ์›น ํŽ˜์ด์ง€์—์„œ ์Šคํฌ๋กค์„ ํ•˜๋Š” ๋Œ€์ƒ์ด ๋ธŒ๋ผ์šฐ์ € ํ™”๋ฉด์ด๊ธฐ ๋•Œ๋ฌธ์— ์œˆ๋„์šฐ ๊ฐ์ฒด์— ์ด๋ฒคํŠธ๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.
ย 
์ด๊ฒƒ์„ ์ด์šฉํ•ด pageYOffset ๊ฐ’์ด 10์„ ๋„˜์–ด๊ฐ€๊ฒŒ ๋˜๋ฉด ์œ„์— ์žˆ๋Š” header๋ฅผ ๊ณ ์ •์‹œ์ผœ ๊ฐ™์ด ์ด๋™ํ•˜๋Š” ๊ธฐ๋Šฅ์„ ๋งŒ๋“ค๊ฒ ์Šต๋‹ˆ๋‹ค.
notion imagenotion image
ย 
ํŒŒ์ผ๋ช… : css/style.css
... #header{ ... } #header.on{ position: fixed; /* ์ƒ๋‹จ์— ๊ณ ์ •๋˜์„œ ๊ฐ™์ด ์›€์ง์ž„ */ } #header .inner{ ... transition: all 1s; /* ์ž์—ฐ์Šค๋Ÿฌ์šด ํšจ๊ณผ */ } #header.on .inner{ height: 52px; } ...
ย 
ํŒŒ์ผ๋ช… : js/main.js
const heart = document.querySelector( '.heart_btn'); // ํ•˜ํŠธ ์š”์†Œ ๋ถ€๋ถ„์„ ์„ ํƒํ•ด์„œ ๊ฐ€์ ธ์˜ด const header = document.querySelector('#header'); heart.addEventListener('click', function(){ console.log('hit'); heart.classList.toggle('on'); // ํ•˜ํŠธ๋ฅผ ํด๋ฆญํ•˜๋ฉด .on ํด๋ž˜์Šค๋ฅผ ์ถ”๊ฐ€ }); function scrollFunc(){ // console.log(pageYOffset); if(pageYOffset >= 10){ // ๋“œ๋ž˜๊ทธํ•  ๊ฒฝ์šฐ header.classList.add('on'); }else{ header.classList.remove('on'); } } window.addEventListener('scroll', scrollFunc); // ์Šคํฌ๋กค ์ด๋ฒคํŠธ ๋ฐœ์ƒ ์‹œ scrollFunc ์‹คํ–‰
ย 
๋จผ์ € ์ปจํ…์ธ  ๋ฐ•์Šค๋ฅผ ๋ณต์‚ฌํ•˜์—ฌ ์Šคํฌ๋กคํ•  ์ˆ˜ ์žˆ์„ ์ •๋„๋กœ ๋งŒ๋“ค์–ด์ฃผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. ๋˜ํ•œ ์Šคํฌ๋กค ๋˜๋Š” ๋™์•ˆ ์ธ์Šคํƒ€๊ทธ๋žจ ๋กœ๊ณ ๊ฐ€ ์‚ฌ๋ผ์ง€๋Š” ๊ธฐ๋Šฅ ๋˜ํ•œ ์ถ”๊ฐ€ํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
notion imagenotion image
notion imagenotion image
ย 
ํŒŒ์ผ๋ช… : css/style.css/
... #header .inner .logo .sprite_insta_icon:after{ ... transition: all .5s; } ... #header .right_icons{ width: 132px; /* ๋ถ€๋ชจ๊ฐ’ ์ขŒ์šฐ๊ฐ’ ๊ณ ์ • */ display: flex; justify-content: space-between; /* x์ถ• ์ •๋ ฌ_๊ณต๊ฐ„์„ ์ž๋™์œผ๋กœ ๋ถ„๋ฐฐํ•จ */ } #header .inner .logo div:nth-child(2){ transform:translateY(2px); transition:all .5s; } #header.on .inner .logo .sprite_insta_icon:after{ opacity:0; } #header.on .inner .logo div:nth-child(2){ opacity:0; } /* ์•„์ด์ฝ˜ ์‚ฌ๋ผ์ง€๊ฒŒ ํ•˜๋Š” ๋ถ€๋ถ„ */ ...
ย 
side_box๋„ ์Šคํฌ๋กคํ•˜์—ฌ๋„ ๋”ฐ๋ผ์„œ ์›€์ง์ด๋„๋ก ์ด๋ฒคํŠธ๋ฅผ ์ถ”๊ฐ€ํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
notion imagenotion image
ย 
ํŒŒ์ผ๋ช… : js/main.js
const heart = document.querySelector('.heart_btn'); // ํ•˜ํŠธ ์š”์†Œ ๋ถ€๋ถ„์„ ์„ ํƒํ•ด์„œ ๊ฐ€์ ธ์˜ด const header = document.querySelector( '#header'); const sidebox = document.querySelector( '.side_box'); heart.addEventListener('click',function(){ console.log('hit'); heart.classList.toggle('on'); // ํ•˜ํŠธ๋ฅผ ํด๋ฆญํ•˜๋ฉด .on ํด๋ž˜์Šค๋ฅผ ์ถ”๊ฐ€ }); function resizeFunc(){ if(pageYOffset >= 10){ let calcWidth = (window.innerWidth *0.5) +167; // ์›น ํŽ˜์ด์ง€ ๊ธฐ๋ฐ˜์œผ๋กœ ์œ„์น˜ ์žฌ์กฐ์ • sidebox.style.left = calcWidth +'px'; } } function scrollFunc(){ // console.log(pageYOffset); if(pageYOffset >= 10){ // ๋“œ๋ž˜๊ทธํ•  ๊ฒฝ์šฐ header.classList.add('on'); sidebox.classList.add('on'); }else{ header.classList.remove('on'); sidebox.classList.remove('on'); } } window.addEventListener('scroll', scrollFunc); // ์Šคํฌ๋กค ์ด๋ฒคํŠธ ๋ฐœ์ƒ ์‹œ scrollFunc ์‹คํ–‰
ย 
ํŒŒ์ผ๋ช… : css/style.css
... .side_box{ ... } .side_box.on{ position: fixed; /* ํ™”๋ฉด์— ๊ณ ์ • */ top: 80px; } ...
ย 
notion imagenotion image
ย 
์ฃผ์˜ํ•˜์‹ค ๋ถ€๋ถ„์ด position: fixed๋Š” position: absolute ์™€ ๋‹ค๋ฅด๊ฒŒ ๊ธฐ์ค€์ ์ด ๋ฌด์กฐ๊ฑด ๋ธŒ๋ผ์šฐ์ €๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์žก๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ๋ ˆ์ด์•„์›ƒ์ธ inner๋ฅผ ๊ธฐ์ค€์ ์œผ๋กœ ์žก๊ณ  ์žˆ๋˜ side_box๊ฐ€ fixed๋กœ ๋ณ€๊ฒฝ๋˜๋ฉด ๋ธŒ๋ผ์šฐ์ €๋ฅผ ๊ธฐ์ค€์œผ๋กœ ์žก๊ฒŒ ๋˜๋ฉด์„œ ์ด์ƒํ•œ ์œ„์น˜๋กœ ์ด๋™ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์Šคํฌ๋กค์„ ๋‚ด๋ฆฌ๊ฒŒ ๋˜์—ˆ์„ ๋•Œ ์œ„์น˜๋ฅผ ๋‹ค์‹œ ์žฌ์กฐ์ • ํ•ด์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
ย 
๊ทธ๋ž˜์„œ resizeFunc ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค์–ด์„œ ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
ย 
ํŒŒ์ผ๋ช… : js/main.js
const heart = document.querySelector('.heart_btn'); // ํ•˜ํŠธ ์š”์†Œ ๋ถ€๋ถ„์„ ์„ ํƒํ•ด์„œ ๊ฐ€์ ธ์˜ด const header = document.querySelector( '#header'); const sidebox = document.querySelector( '.side_box'); heart.addEventListener('click',function(){ console.log('hit'); heart.classList.toggle('on'); // ํ•˜ํŠธ๋ฅผ ํด๋ฆญํ•˜๋ฉด .on ํด๋ž˜์Šค๋ฅผ ์ถ”๊ฐ€ }); function resizeFunc(){ if(pageYOffset >= 10){ let calcWidth = (window.innerWidth *0.5) +167; // ์›น ํŽ˜์ด์ง€ ๊ธฐ๋ฐ˜์œผ๋กœ ์œ„์น˜ ์žฌ์กฐ์ • // console.log(window.innerWidth); sidebox.style.left = calcWidth +'px'; } } function scrollFunc(){ // console.log(pageYOffset); if(pageYOffset >= 10){ // ๋“œ๋ž˜๊ทธํ•  ๊ฒฝ์šฐ header.classList.add('on'); sidebox.classList.add('on'); resizeFunc(); }else{ header.classList.remove('on'); sidebox.classList.remove('on'); sidebox.removeAttribute('style'); } } window.addEventListener('scroll', scrollFunc); // ์Šคํฌ๋กค ์ด๋ฒคํŠธ ๋ฐœ์ƒ ์‹œ scrollFunc ์‹คํ–‰
ย 
notion imagenotion image
ย 
CSS์—์„œ ์Šคํฌ๋กค์— ๋”ฐ๋ผ ๊ณ ์ •๋˜์„œ ์ด๋™ํ•˜๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด์„œ position: fixed; ๋ฅผ ์‚ฌ์šฉํ•œ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ position: fixed๋Š” ์›น ํŽ˜์ด์ง€๋ฅผ ๊ธฐ์ค€์œผ๋กœ๋งŒ ์œ„์น˜๋ฅผ ์ •ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋ ˆ์ด์•„์›ƒ ๊ธฐ๋ฐ˜์œผ๋กœ ์œ„์น˜๊ฐ€ ์ •ํ•ด์กŒ๋˜ side_box์˜ ์œ„์น˜๋ฅผ ๋‹ค์‹œ ์ •ํ•ด์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ resizeFunc์„ ์‚ฌ์šฉํ•˜์—ฌ ์ด๋ฅผ ํ•ด๊ฒฐํ•˜์˜€์Šต๋‹ˆ๋‹ค.
ย 
์ฝ”๋“œ๋ฅผ ์ž˜ ์ž‘์„ฑํ–ˆ๋‹ค๋ฉด ์Šคํฌ๋กค ํ•  ๊ฒฝ์šฐ ์ž˜ ๊ณ ์ •์ด ๋˜๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋ฒˆ์—๋Š” ํ™”๋ฉด์„ ์ค„์˜€์„ ๋•Œ ๋ฐ˜์‘ํ•˜๋Š” ๋ฆฌ์‚ฌ์ด์ฆˆ ์ด๋ฒคํŠธ๋ฅผ ์ถ”๊ฐ€ํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ์œ„์—์„œ ์ž‘์„ฑํ–ˆ๋˜ resizefunc์—์„œ ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•ด์„œ ๋งŒ๋“ค์–ด ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ํ™”๋ฉด์ด ์ปจํ…์ธ  ๋ฐ•์Šค๋ณด๋‹ค ์ž‘์•„์ง€๊ฒŒ ๋˜๋ฉด ์ปจํ…์ธ  ๋ฐ•์Šค๊ฐ€ ๊ทธ์— ๋งž์ถฐ์„œ ์ค„์–ด๋“ค๋„๋ก ์ด๋ฒคํŠธ๋ฅผ ์ž‘์„ฑํ•ด ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.
ย 
ํŒŒ์ผ๋ช… : js/main.js
const heart = document.querySelector( '.heart_btn'); // ํ•˜ํŠธ ์š”์†Œ ๋ถ€๋ถ„์„ ์„ ํƒํ•ด์„œ ๊ฐ€์ ธ์˜ด const header = document.querySelector( '#header'); const sidebox = document.querySelector( '.side_box'); heart.addEventListener('click', function(){ console.log('hit'); heart.classList.toggle('on'); // ํ•˜ํŠธ๋ฅผ ํด๋ฆญํ•˜๋ฉด .on ํด๋ž˜์Šค๋ฅผ ์ถ”๊ฐ€ }); function resizeFunc(){ // console.log('resize!!'); if(pageYOffset >= 10){ let calcWidth = (window.innerWidth *0.5) +167; // ์›น ํŽ˜์ด์ง€ ๊ธฐ๋ฐ˜์œผ๋กœ ์œ„์น˜ ์žฌ์กฐ์ • // console.log(window.innerWidth); sidebox.style.left = calcWidth +'px'; } } function scrollFunc(){ // console.log(pageYOffset); if(pageYOffset >= 10){ // ๋“œ๋ž˜๊ทธํ•  ๊ฒฝ์šฐ header.classList.add('on'); sidebox.classList.add('on'); resizeFunc(); }else{ header.classList.remove('on'); sidebox.classList.remove('on'); sidebox.removeAttribute('style'); } } window.addEventListener( 'resize', resizeFunc); window.addEventListener( 'scroll', scrollFunc); // ์Šคํฌ๋กค ์ด๋ฒคํŠธ ๋ฐœ์ƒ ์‹œ scrollFunc ์‹คํ–‰
ย 
์ปจํ…์ธ  ๋ฐ•์Šค์˜ ํฌ๊ธฐ๊ฐ€ ๋ชจ๋ฐ”์ผ๋กœ ๊ฐ”์„ ๋•Œ ๋„ˆ๋ฌด ํฌ๊ฒŒ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค. ๋ชจ๋ฐ”์ผ๋กœ ๊ฐ”์„ ๋•Œ ํ•ด์ƒ๋„์˜ ํฌ๊ธฐ๋ณด๋‹ค ์ปค์ง€๊ฒŒ ๋˜๋ฉด ์ขŒ์šฐ๊ฐ€ ํ”๋“ค๋ฆฌ๊ฑฐ๋‚˜ ๋ฌธ์ œ๊ฐ€ ์ƒ๊น๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ ์ปจํ…์ธ ๋“ค์ด ์ขŒ์šฐ๊ฐ’์ด ๋ฆฌ์‚ฌ์ด์ฆˆ๋ฅผ ํ•˜๊ฒŒ ๋˜๋ฉด ํ™”๋ฉดํฌ๊ธฐ์— ๋งž์ถฐ์„œ ์ขŒ์šฐ๊ฐ’์ด ์œ ์ง€๋˜๋„๋ก ๋งŒ๋“ค์–ด ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
ย 
ํŒŒ์ผ๋ช… : js/main.js
const heart = document.querySelector( '.heart_btn'); // ํ•˜ํŠธ ์š”์†Œ ๋ถ€๋ถ„์„ ์„ ํƒํ•ด์„œ ๊ฐ€์ ธ์˜ด const header = document.querySelector( '#header'); const sidebox = document.querySelector( '.side_box'); // SelectorAll์„ ํ™œ์šฉํ•ด ๋ชจ๋“  ์š”์†Œ๋ฅผ ๊ฐ€์ ธ์˜ด const variableWidth = document.querySelectorAll(".contents_box .contents"); heart.addEventListener('click', function(){ console.log('hit'); heart.classList.toggle('on'); // ํ•˜ํŠธ๋ฅผ ํด๋ฆญํ•˜๋ฉด .on ํด๋ž˜์Šค๋ฅผ ์ถ”๊ฐ€ }); function resizeFunc(){ // console.log('resize!!'); if(pageYOffset >= 10){ let calcWidth = (window.innerWidth *0.5) +167; // ์›น ํŽ˜์ด์ง€ ๊ธฐ๋ฐ˜์œผ๋กœ ์œ„์น˜ ์žฌ์กฐ์ • // console.log(window.innerWidth); sidebox.style.left = calcWidth +'px'; } if(matchMedia('screen and (max-width : 800px)').matches){ // ์—ฌ๋Ÿฌ๊ฐœ์˜ ์ปจํ…์ธ  ๋ฐ•์Šค๊ฐ€ ์žˆ์œผ๋ฏ€๋กœ ๋ฐฐ์—ด ํ™œ์šฉ for(let i=0; i<variableWidth.length; i++){ variableWidth[i].style.width = window.innerWidth -20 +'px'; } }else{ for(let i=0; i<variableWidth.length; i++){ variableWidth[i].removeAttribute('style'); } } } function scrollFunc(){ console.log(pageYOffset); if(pageYOffset >= 10){ // ๋“œ๋ž˜๊ทธํ•  ๊ฒฝ์šฐ header.classList.add('on'); sidebox.classList.add('on'); resizeFunc(); }else{ header.classList.remove( 'on'); sidebox.classList.remove( 'on'); sidebox.removeAttribute( 'style'); } } window.addEventListener( 'resize', resizeFunc); window.addEventListener( 'scroll', scrollFunc); // ์Šคํฌ๋กค ์ด๋ฒคํŠธ ๋ฐœ์ƒ ์‹œ scrollFunc ์‹คํ–‰
ย 
width๊ฐ’์ด 800 ์ดํ•˜์—์„œ๋Š” element.style๊ฐ’์ด width๊ฐ’์„ ์กฐ์ • ํ•˜๊ณ  width๊ฐ’ 800 ์ด์ƒ์—์„œ๋Š” style๊ฐ’์ด ์‚ฌ๋ผ์ง€๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
notion imagenotion image
notion imagenotion image
ย 
์™„์„ฑ๋œ ์ฝ”๋“œ๋Š” ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.
ย 
ํŒŒ์ผ๋ช… : js/main.js
const heart = document.querySelector( '.heart_btn'); // ํ•˜ํŠธ ์š”์†Œ ๋ถ€๋ถ„์„ ์„ ํƒํ•ด์„œ ๊ฐ€์ ธ์˜ด const header = document.querySelector( '#header'); const sidebox = document.querySelector( '.side_box'); // SelectorAll์„ ํ™œ์šฉํ•ด ๋ชจ๋“  ์š”์†Œ๋ฅผ ๊ฐ€์ ธ์˜ด const variableWidth = document.querySelectorAll(".contents_box .contents"); heart.addEventListener('click', function(){ console.log('hit'); heart.classList.toggle('on'); // ํ•˜ํŠธ๋ฅผ ํด๋ฆญํ•˜๋ฉด .on ํด๋ž˜์Šค๋ฅผ ์ถ”๊ฐ€ }); function resizeFunc(){ // console.log('resize!!'); if(pageYOffset >= 10){ let calcWidth = (window.innerWidth *0.5) +167; // ์›น ํŽ˜์ด์ง€ ๊ธฐ๋ฐ˜์œผ๋กœ ์œ„์น˜ ์žฌ์กฐ์ • // console.log(window.innerWidth); sidebox.style.left = calcWidth +'px'; } if(matchMedia('screen and (max-width : 800px)').matches){ // ์—ฌ๋Ÿฌ๊ฐœ์˜ ์ปจํ…์ธ  ๋ฐ•์Šค๊ฐ€ ์žˆ์œผ๋ฏ€๋กœ ๋ฐฐ์—ด ํ™œ์šฉ for(let i=0; i<variableWidth.length; i++){ variableWidth[i].style.width = window.innerWidth -20 +'px'; } }else{ for(let i=0; i<variableWidth.length; i++){ variableWidth[i].removeAttribute('style'); } } } function scrollFunc(){ console.log(pageYOffset); if(pageYOffset >= 10){ // ๋“œ๋ž˜๊ทธํ•  ๊ฒฝ์šฐ header.classList.add('on'); sidebox.classList.add('on'); resizeFunc(); }else{ header.classList.remove( 'on'); sidebox.classList.remove( 'on'); sidebox.removeAttribute( 'style'); } } window.addEventListener( 'resize', resizeFunc); window.addEventListener( 'scroll', scrollFunc); // ์Šคํฌ๋กค ์ด๋ฒคํŠธ ๋ฐœ์ƒ ์‹œ scrollFunc ์‹คํ–‰
ย 
ํŒŒ์ผ๋ช… : 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.on{ position: fixed; /* ์ƒ๋‹จ์— ๊ณ ์ •๋˜์„œ ๊ฐ™์ด ์›€์ง์ž„ */ } #header .inner{ /* inner ์•ˆ์— ์ปจํ…์ธ ๋ฅผ ๋„ฃ์œผ๋ฉด ์•ˆ์— ๊ฐ’์ด ๋“ค์–ด์˜ด */ width: 975px; height: 77px; margin: 0 auto; /* ๊ฐ€์šด๋ฐ ์ •๋ ฌ */ display: flex; /* ๊ฐ€๋กœ ๋ฐฐ์น˜ */ justify-content: space-between; /* x์ถ• ์ •๋ ฌ_๊ณต๊ฐ„์„ ์ž๋™์œผ๋กœ ๋ถ„๋ฐฐํ•จ */ align-items: center; /* y์ถ• ์ •๋ ฌ */ transition: all 1s; /* ์ž์—ฐ์Šค๋Ÿฌ์šด ํšจ๊ณผ */ } #header.on .inner{ height: 52px; } #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; transition: all .5s; } #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); transition:all .5s; } #header.on .inner .logo .sprite_insta_icon:after{ opacity:0; } #header.on .inner .logo div:nth-child(2){ opacity:0; } /* ์•„์ด์ฝ˜ ์‚ฌ๋ผ์ง€๊ฒŒ ํ•˜๋Š” ๋ถ€๋ถ„ */ #header .inner .logo .sprite_insta_icon{ position: relative; /* after์—๊ฒŒ ์œ„์น˜ ๊ธฐ์ค€์„ ์ „๋‹ฌํ•ด์ฃผ๊ธฐ ์œ„ํ•จ */ margin-right: 30px; } #main_container{ padding-top: 130px; display: flex; /* ์ปจํ…์ธ ๊ฐ€ ๊ฐ€์šด๋ฐ์— ์œ„์น˜ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•จ */ justify-content: center; /* x์ถ• ๊ฐ€์šด๋ฐ ์ •๋ ฌ */ } #main_container .inner{ width: 935px; /* height: 500px; */ /* background: red; */ position: relative; /* ๊ธฐ์ค€์ ์„ inner๋กœ ๋ณ€๊ฒฝํ•˜๊ธฐ ์œ„ํ•จ */ } .contents_box{ } .contents{ width: 614px; /* height: 500px; */ border: 1px solid rgba(0,0,0,0.09); border-radius: 3px; /* ํ…Œ๋‘๋ฆฌ๋ฅผ ๋‘ฅ๊ธ€๊ฒŒ ๋งŒ๋“ฌ */ margin-bottom: 60px; /* ๋‹ค๋ฅธ contents๋“ค์ด ๋ฐ€๋ ค์•ผ ๋˜๊ธฐ ๋•Œ๋ฌธ์— ์‚ฌ์ด์— ์—ฌ๋ฐฑ์„ ์ค€๋‹ค */ background: white; } .contents .top{ display: flex; /* ๊ฐ€๋กœ ๋ฐฐ์น˜ */ justify-content: space-between; /* x์ถ• ์ •๋ ฌ_๊ณต๊ฐ„์„ ์ž๋™์œผ๋กœ ๋ถ„๋ฐฐ */ align-items: center; padding: 10px 20px; /* ์œ„์•„๋ž˜ ์–‘์ชฝ */ } .contents .top .profile_img{ width: 32px; height: 32px; border-radius: 50%; /* ํ…Œ๋‘๋ฆฌ๋ฅผ ๋‘ฅ๊ธ€๊ฒŒ ์„ค์ • 50% -> ์›์˜ ํ˜•ํƒœ */ overflow: hidden; /* ์ž์‹์ด ํฌ๊ธฐ๊ฐ€ ๋„˜์น˜์ง€ ์•Š๋„๋ก ํ•œ๋‹ค */ margin-right: 10px; } .contents .top .profile_img img{ width: 100%; /* 100%๊ฐ€ ์—†์„ ๊ฒฝ์šฐ ์ด๋ฏธ์ง€๊ฐ€ ๋“ค์–ด๊ฐ€์ง€ ์•Š์Œ */ } .contents .top .user_container{ display: flex; /* ๊ฐ€๋กœ ๋ฐฐ์น˜ */ } .m_text{ font-size: 14px; font-weight: bold; } .s_text{ font-size: 12px; } .contents .img_section{ overflow: hidden; /* ์ž์‹์ด ๋ถ€๋ชจ์˜ ํฌ๊ธฐ๋ฅผ ๋„˜์ง€ ์•Š๋„๋ก ํ•œ๋‹ค */ } .contents .img_section img{ width: 100%; /* ๋ถ€๋ชจ์˜ ํฌ๊ธฐ 100%๋ฅผ ๋ฐ›๋Š”๋‹ค */ } .contents .bottom_icons{ display: flex; /* ๊ฐ€๋กœ ๋ฐฐ์น˜ */ justify-content: space-between; /* x์ถ• ์ •๋ ฌ_๊ณต๊ฐ„์„ ์ž๋™์œผ๋กœ ๋ถ„๋ฐฐํ•จ */ align-items: center; /* y์ถ• ๊ฐ€์šด๋ฐ ์ •๋ ฌ */ padding: 10px 20px; } .contents .bottom_icons .left_icons{ display: flex; /* ๊ฐ€๋กœ ๋ฐฐ์น˜ */ } .contents .bottom_icons .left_icons > div{ margin-right: 10px; } .heart_btn.on .sprite_heart_icon_outline{ /* on ํด๋ž˜์Šค๊ฐ€ ์ถ”๊ฐ€ ๋œ ๊ฒฝ์šฐ ์ด๋ฏธ์ง€๋ฅผ ๋ณ€๊ฒฝ */ background: url('../imgs/background01.png') no-repeat -26px -261px; } .contents .likes{ padding: 5px 20px; color: #262626; } .contents .comment_container{ display: flex; /* ๊ฐ€๋กœ ๋ฐฐ์น˜ */ justify-content: space-between; align-items: center; padding: 5px 20px; } .contents .comment_container .comment{ display: flex; /* ๊ฐ€๋กœ ๋ฐฐ์น˜ */ font-size: 14px; } .contents .comment_container .comment .nick_name{ margin-right: 10px; /* ์•„์ด๋””์™€ ๋Œ“๊ธ€ ๊ฐ„์˜ ๊ฑฐ๋ฆฌ ์„ค์ • */ } .contents .timer{ font-size: 10px; letter-spacing: 0.2px; /* ์ž๊ฐ„ ์กฐ์ • */ color: #999; border-bottom: 1px solid rgba(0,0,0,0.09); /* ์•„๋ž˜์ชฝ ์‹ค์„  ์ถ”๊ฐ€ */ padding: 10px 20px; } .contents .comment_field{ min-height: 56px; padding: 0 20px; position: relative; /* ์ž์‹๋“ค์ด absolute๋กœ ์ž๋ฆฌ๋ฅผ ์žก๊ธฐ ์œ„ํ•จ */ } .contents .comment_field input{ width: 100%; height: 56px; border: none; outline: none; background: transparent; /* ํˆฌ๋ช…ํ•˜๊ฒŒ ์„ค์ • */ } .contents .comment_field input:focus ~ .upload_btn{ pointer-events: initial; /* ํฌ์ธํ„ฐ ์ด๋ฒคํŠธ ์ดˆ๊ธฐํ™” */ opacity: 1; } .contents .comment_field .upload_btn{ color: #3897f0; position: absolute; right: 20px; top: 50%; transform: translateY(-50%); /* y์ถ•์œผ๋กœ ์ค‘์•™ ์ •๋ ฌ */ cursor: pointer; pointer-events: none; /* ์ฒ˜์Œ์—๋Š” ํด๋ฆญ์ด ๋˜์ง€ ์•Š๋„๋ก ํ•œ๋‹ค */ opacity: 0.6; } .contents .bottom_icons .right_icon > div{ cursor: pointer; /* ๋ˆ„๋ฅผ ์ˆ˜ ์žˆ๋„๋ก ํ•˜๊ธฐ ์œ„ํ•จ */ } .side_box{ width: 293px; /* height: 300px; */ /* background: rgba(255,0,0,0.16); */ position: absolute; /* ๋ถ€๋ชจ๋ฅผ ๊ฐ–๋Š” ๊ธฐ์ค€์ ์„ ์žก์ง€ ์•Š์œผ๋ฉด ๊ผญ๋Œ€๊ธฐ๊นŒ์ง€ ์˜ฌ๋ผ๊ฐ */ right: 0; top: 0; } .side_box.on{ position: fixed; /* ํ™”๋ฉด์— ๊ณ ์ • */ top: 80px; } .side_box .profile_thumb{ width: 50px; height: 50px; border-radius: 50%; overflow: hidden; /* ์ด๋ฏธ์ง€๊ฐ€ ๋„˜์น˜์ง€ ์•Š๋„๋ก ํ•œ๋‹ค */ margin-right: 10px; } .side_box .profile_thumb img{ width: 100%; height: 100%; } .side_box .user_profile{ display: flex; /* ๊ฐ€๋กœ ๋ฐฐ์น˜ */ align-items: center; font-size: 14px; color: #262626; } .side_box .detail .id{ margin-bottom: 5px; } .side_box .detail .ko_name{ font-size: 12px; color: #999; } .side_box > article{ border: 1px solid rgba(0,0,0,0.09); border-radius: 3px; margin-bottom: 20px; width: 291px; font-size: 14px; color: #262626; font-weight: bold; background: white; } .side_box > article > header{ display: flex; /* ๊ฐ€๋กœ ๋ฐฐ์น˜ */ align-items: center; justify-content: space-between; padding: 15px 20px; color: #999; } .side_box > article > header .more{ font-size: 12px; color: #262626; cursor: pointer; } .thumb_user{ display: flex; align-items: center; padding: 10px 20px; } .thumb_user .profile_thumb{ width: 34px; /* ํฌ๊ธฐ๊ฐ€ ์ข€ ๋” ์ž‘๊ฒŒ ๋งŒ๋“ฌ */ height: 34px; } .thumb_user .time{ font-size: 10px; letter-spacing: 0.2px; color: #999; } .side_box .scroll_inner{ height: 182px; overflow-x: hidden; /* x์ถ•_์ž์‹์ด ๋ถ€๋ชจ ๋„˜์ง€ ๋ชปํ•˜๊ฒŒ ํ•œ๋‹ค */ overflow-y: auto; /* ์ž๋™์œผ๋กœ ์Šคํฌ๋กค์„ ๋ณด์—ฌ์ฃผ๊ฑฐ๋‚˜ ์ˆจ๊น€ */ /* overflow: hidden auto; x์ถ•, y์ถ• ํ•œ๋ฒˆ์— ์„ค์ • */ } .hidden_menu{ display: none; width: 600px; /* background: red; */ position: absolute; left: 50%; transform: translateX(-50%); /* x์ถ• ๊ฐ€์šด๋ฐ ์ •๋ ฌ */ top: 100px; overflow: hidden; /* ์ž์‹๋“ค์ด ๋„˜์น˜์ง€ ์•Š๋„๋ก ํ•œ๋‹ค */ border: 1px solid rgba(0,0,0,0.09); border-radius: 3px; } .hidden_menu .scroll_inner{ height: 100px; /* ๋†’์ด๊ฐ’์„ ์ž์‹์—๊ฒŒ ์ค€๋‹ค */ width: auto; overflow-x: auto; /* ํ•ญ๋ชฉ์ด ๋งŽ์•„์งˆ ๊ฒฝ์šฐ ์•Œ์•„์„œ ์Šคํฌ๋กค์ด ์ƒ์„ฑ */ overflow-y: hidden; display: flex; /* ๊ฐ€๋กœ๋ฐฐ์น˜ */ align-items: center; padding: 0 10px; } .hidden_menu .scroll_inner .user{ width: 80px; height: 80px; display: flex; flex-direction: column; /* ๊ฐ€๋กœ ์ค‘์•™ ์ •๋ ฌ์„ ์„ธ๋กœ ์ค‘์•™ ์ •๋ ฌ๋กœ ๋ณ€๊ฒฝ */ align-items: center; margin-right: 15px; justify-content: space-between; /* ์ด๋ฏธ์ง€๋Š” ์œ„๋กœ ์•„์ด๋””๋Š” ์•„๋ž˜๋กœ ์„ค์ • */ } .hidden_menu .scroll_inner .user .id{ font-size: 12px; color: #262626; } .hidden_menu .thumb_img{ width: 56px; height: 56px; border-radius: 50%; overflow: hidden; } .hidden_menu .thumb_img img{ width: 100%; height: 100%; } @media screen and (max-width:1000px){ #header .inner{ width: 97.5%; } #main_container{ padding-top: 220px; } #main_container .inner{ width: 93.5%; } .contents_box{ display: flex; flex-direction: column; /* ์„ธ๋กœ ๋ฐฐ์น˜ ๋ฐ›๋„๋ก ํ•œ๋‹ค */ align-items: center; /* ์™ผ์ชฝ์œผ๋กœ ์น˜์šฐ์ณ ์ง€๋Š” ๊ฑธ ๋ฐฉ์ง€ */ } .side_box{ /* ์‚ฌ์ด๋“œ ๋ฐ•์Šค ์ˆจ๊ธฐ๊ธฐ */ display: none; } .hidden_menu{ display: block; } } @media screen and (max-width:650px){ #header .search_box{ display: none; } .hidden_menu{ width: 95%; } }