Submitted over 2 years ago
Responsive landing page HTLM, SCSS, VANILLA JS, GRID, MOBILE FIRST
@T4R0TARO
Design comparison
SolutionDesign
Solution retrospective
All feedback is welcomed 😊 I want to improve this function
outsideDivClose() : if the mobile menu is open, close mobile menu when clicked outside element
⚠Issue: when clicked on header section the mobile menu remains
-attempt1: addEventListener to 'container' but mobile menu will be included
-attempt2: addEventListener to document but mobile menu will be included
-attempt3: addEventListener to 'main' but top header is not included
//CODE
const main = document.querySelector("main");
// CLICK OUT OF NAV/ CLOSE NAV
const outsideDivClose = function(){
if(nav.classList.contains('active')){
nav.classList.remove('active')
}
}
main.addEventListener('click', outsideDivClose);
Community feedback
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord