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%๋ก ์ง์ ํ์์.