[miniProjects] 07_Split Landing Page

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

miniProjects

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

07_Split Landing Page

๐Ÿ’ป ์ฃผ์ œ : ๋ฐ˜์œผ๋กœ ๋‚˜๋‰œ ํ™”๋ฉด์—์„œ ๋งˆ์šฐ์Šค ์ด๋™ ์‹œ ํ™”๋ฉด์ด ์ปค์ง€๊ณ , ๋ฒ„ํŠผ์— ๋งˆ์šฐ์Šค๋ฅผ ์˜ฌ๋ ค๋‘๋ฉด ๋ฒ„ํŠผ ์ƒ‰์ด ๋ณ€ํ•จ.

  • mouseenter, mouseleave ๋ฉ”์„œ๋“œ๋ฅผ ํ†ตํ•ด classList์˜ add, remove๋ฅผ ์‹คํ–‰ํ•จ.


const left = document.querySelector('.left'); 
const right = document.querySelector('.right'); 
const container = document.querySelector('.container');

left.addEventListener('mouseenter', () => container.classList.add('hover-left'));
left.addEventListener('mouseleave', () => container.classList.remove('hover-left'));

right.addEventListener('mouseenter', () => container.classList.add('hover-right'));
right.addEventListener('mouseleave', () => container.classList.remove('hover-right'));
:root {
  --left-bg-color : rgba(255, 123, 84, .7);
  --right-bg-color : rgba(147, 155, 98, .7);
  --left-btn-hover-color : rgba(255, 123, 84, 1);
  --right-btn-hover-color : rgba(147, 155, 98, 1);
  --hover-width : 75%;
  --other-width : 25%;
  --speed: 1000ms
}

.hover-left .left {
  width: var(--hover-width);
}

.hover-left .right {
  width: var(--other-width);
}

.hover-right .right {
  width: var(--hover-width);
}

.hover-right .left {
  width: var(--other-width);
}

๐Ÿ‘๐Ÿป hover ๋˜์—ˆ์„ ๋•Œ ํ™”๋ฉด ๋น„์œจ์„ 75%๋กœ ์ง€์ •ํ•˜์˜€์Œ.

profile
์ •์‹ ์ฐจ๋ ค ์ด ๊ฐ๋ฐ•ํ•œ ์„ธ์ƒ์†์—์„œ

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