How can I shrink the right side div when the left navigation menu is open? Here are the code examples,
HTML :
<div id="home" class="full"><p>Home</p></div>
<div id="about" class="full"><p>About</p></div>
<div id="portfolio" class="full"><p>Portfolio</p></div>
<div id="skills" class="full"><p>Skills</p></div>
<div id="contact" class="full"><p>Contact</p></div>
Css :
.full{height: 100vh;color: #fff;}
.PageShrink{margin-left: 30vh;}
JS:
const fullPage = document.querySelector('.full');
let menuOpen = false;
menuBtn.addEventListener('click', () => {
if(!menuOpen) {
fullPage.classList.add('PageShrink');
menuOpen = true;
} else {
fullPage.classList.remove('PageShrink');
menuOpen = false;
}
});
When clicking on the menuBtn to slide in from the left, the Home section shrinks by 30vh as expected. However, it seems that subsequent clicks on About, Portfolio, etc., do not trigger the shrinking effect even though they have the same class applied. The issue only works on the first div i.e., home. Any assistance would be greatly appreciated.
Thank you for your help!