Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Responsive news home page

Henry 120

@Ace-droid

Desktop design screenshot for the News homepage coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


could not figure out how to blur the background and stop the scrolling when the menu is opened. any feedbackis welcome

Community feedback

@Jahan-Shah

Posted

Hey Henry 👋, Congratulation on solving this challenge

  • To add blur in the background when the nav is open you can add a div (backdrop) behind the nav with 100% width and height and then add blur to that div.

  • To stop scroll when nav is open you can modify you js function like this:

const menuButton = document.querySelector(".hamburger");
const navLinks = document.querySelector(".nav-links");
const body = document.querySelector("body");

let isNavOpen = false;

menuButton.addEventListener("click", () => {
  isNavOpen = !isNavOpen;
  if (isNavOpen) {
    body.style.overflowY = "hidden";
  } else {
    body.style.overflowY = "auto";
  }
  menuButton.classList.toggle("is-active");
  navLinks.classList.toggle("is-active");
  body.classList.toggle("blur");
  body.classList.toggle("fixed");
});

I hope this will help

Happy Coding 👨‍💻

1
Henry 120

@Ace-droid

Posted

not still clear on the background blur though if you could explain that in a bit more detail that would be great....thanks again for the feedback

0
Henry 120

@Ace-droid

Posted

oh my bad, it actually worked just made some typos.

0
Henry 120

@Ace-droid

Posted

hey shahjahan, thanks for the feedback really appreciate it, but the solution you showed only stops the scrolling on the body when the menu is closed not when it is opened

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join 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