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

Blogr Landing Page with CSS Grid

#accessibility#sass/scss
kxnzxā€¢ 870

@kxnzx

Desktop design screenshot for the Blogr landing page coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


Hello Frontend Mentor community,

Does anyone know why my menu (in the Mobile View) does not display when the toggleButton has been clicked? How can I fix it?

Your help is much appreciated!

Community feedback

Chrisā€¢ 520

@9CB5

Posted

The display: none in .menuList takes precedence over the .displayMenu class that you toggle when you click the button. So the menu will never show. There are two ways you can solve this:

1.) Hacky but quicker way. Add an !important keyword to display: block inside the .displayMenu class. But bear in mind this is bad practice as you're bypassing the natural order of precedence of your CSS.

2.) Modify the display: none in .menuList using JS with something like menu.style.display = "block" when the hamburger is clicked.

Marked as helpful

0

kxnzxā€¢ 870

@kxnzx

Posted

@9CB5 Hello Chris, thank you for your clear explanation. I choose to solve it with your second solution, it works now! Much appreciated! :)

At the time I finished the CSS I realized that it was unnecessary for me to wrap the <ul class="menuListItems"> inside the <div class="menuList">. I didn't want to correct it, because it would mess up the whole layout. Is this where it went wrong with the precedence? In other words if I did not have the <div class="menuList"> wrapped around <ul class="menuListItems"> would this prevented me from having this issue?

1
Chrisā€¢ 520

@9CB5

Posted

@kxnzx No, because the issue lies in <div class="menuList"> which is the parent element.

When the hamburger button is clicked, the statement above becomes <div class="menuList displayMenu">

So now, you have two competing classes in your menu, and whichever class that is declared last in your css file takes precedence.

In your css file, .displayMenu and .menuList is declared at line 102 and 105 respectively. So .menuList takes precedence.

Marked as helpful

0
kxnzxā€¢ 870

@kxnzx

Posted

@9CB5 I replaced the .displayMenu below .menuList so that .displayMenu takes precedence, this however also did not work.

1
Chrisā€¢ 520

@9CB5

Posted

@kxnzx You have modified your SASS file but forgot to compile it to CSS. It should work once you've done this :)

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