[miniProjects] 45_Netflix Navigation

๋ณด๋ฆฌยท2023๋…„ 8์›” 8์ผ
0

miniProjects

๋ชฉ๋ก ๋ณด๊ธฐ
45/47

45_Netflix Navigation

๐Ÿ’ป ์ฃผ์ œ : ๋ฐ˜์‘ํ˜• ๋„ค๋น„๊ฒŒ์ด์…˜

โœจJS

open_btn.addEventListener('click', () => {
  nav.forEach(nav_el => nav_el.classList.add('visible'))
})

close_btn.addEventListener('click', () => {
  nav.forEach(nav_el => nav_el.classList.remove('visible'))
})
  • nav ํด๋ž˜์Šค๋ฅผ ๊ฐ€์ง„ ๊ฒƒ์— visible ํด๋ž˜์Šค ์ด๋ฆ„์„ ์ถ”๊ฐ€, ์ œ๊ฑฐํ•จ์œผ๋กœ์จ ๋„ค๋น„๊ฒŒ์ด์…˜์ด ๋‚˜ํƒ€๋‚ฌ๋‹ค ์‚ฌ๋ผ์ง.

โœจCSS

.nav {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  /* ํ™”๋ฉด ๋ฐ–์œผ๋กœ */
  transform: translateX(-100%);
  transition: transform .3s ease-in-out;
}
  • ์ฒ˜์Œ ํ™”๋ฉด์—์„œ ํ–„๋ฒ„๊ฑฐ ๋ฐ”๋งŒ ๋ณด์—ฌ์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— x์ถ•์œผ๋กœ -100% ์ด๋™ํ•˜๋ฉด ํ™”๋ฉด์—์„œ ๋„ค๋น„๊ฒŒ์ด์…˜์ด ์•ˆ ๋ณด์ด๊ฒŒ ๋จ.
/* ํ–„๋ฒ„๊ฑฐ๋ฐ” ๋ˆŒ๋ €์„ ๋•Œ ๋‚˜ํƒ€๋‚  ์Šคํƒ€์ผ */
.nav.visible {
  transform: translateX(0);
}

.nav-black {
  background-color: rgb(34, 31, 31);
  width: 60%;
  max-width: 480px;
  min-width: 320px;
  transition-delay: .4s;
}

.nav-black.visible {
  transition-delay: 0s;
}

.nav-red {
  background-color: rgb(229, 9, 20);
  width: 95%;
  transition-delay: .2s;
}

.nav-red.visible {
  transition-delay: .2s;
}

.nav-white {
  background-color: #fff;
  width: 95%;
  padding: 40px;
  position: relative;
  transition-delay: 0s;
}

.nav-white.visible {
  transition-delay: .4s;
}
  • visible์ด ๋ถ™์–ด์žˆ์ง€ ์•Š์„ ๋•Œ์™€ ์žˆ์„ ๋•Œ delay๋ฅผ ์„ค์ •ํ•˜์—ฌ ๋„ค๋น„๊ฒŒ์ด์…˜์ด ๋”์šฑ ๊ทน์ ์ธ ํšจ๊ณผ๋ฅผ ์คŒ.
profile
์ •์‹ ์ฐจ๋ ค ์ด ๊ฐ๋ฐ•ํ•œ ์„ธ์ƒ์†์—์„œ

0๊ฐœ์˜ ๋Œ“๊ธ€