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

News Homepage

@Desiremadeitt

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


My javascript code isn't working help me out with it.

Community feedback

Taqib 390

@taqh

Posted

Hi chinelo 👋, it seems you need to make a few changes

⚫️ The div wrapping the UL is not necessary you can put the navbar-link class on the UL itself.

⚫️ It seems you’re trying to display the mobile Nav on click of the toggle button by adding the ‘active’ class but you don’t actually have a style to hide it for mobile devices.

You can try this:-


@media (max-width: 400px) { 
      .navbar-link { 
          Transform: translateX(100%);
          Display: flex;
          Flex-direction: column;
          Background: white;    
     }
 }; 

This will slide the navbar links out of view on mobile devices

⚫️. You currently have this


      navbar-link.active{
          display: flex;
      }

You should try this instead :-

      navbar-link.active{
          Transform: translateX(0) 
      };

This will slide the mobile nav into view when the button is clicked.

⚫️. Your JavaScript has some issues, you’re adding a class to show the Nav you also need to remove the class when it’s clicked again.

Here’s what you can try instead of what you have written down

  • first you should use a queryselector to target your elements:-
const navToggle = document.querySelector(".toggle-button");
const nav = document.querySelector(".navbar-link");

  • Then this would be the proper way to add a class to you your UL element/Div

toggleButton.addEventListener('click', () => {
nav.classList.add('active')
});

  • Then you can use an if statement to check if it has the active class buy using the
.contains()  

method

You can remove a class by using the

 .remove() 

method

I hope this helps :)

0

@sammyodiagbe

Posted

What do you need javascript for?

0

@Desiremadeitt

Posted

I was supposed to create a hamburger menu with javascript and i wrote the codes but it's not working@sammyodiagbe

0

@hectorHook

Posted

I wish you to feel the power of your dreams in every moment of your life. May success be yours. I wish you to live your passions, which are the protagonists of your success, with every breath. Congratulations 👏 I wish you to feel the power of your dreams in every moment of your life. May success be yours. I wish you to live your passions, which are the protagonists of your success, with every breath. Congratulations

0

@Desiremadeitt

Posted

@hectorHook Thank you

0

@Desiremadeitt

Posted

@hectorHook Thank you

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