I have an unordered inline horizontal list menu, when my mobile media query kicks in I want the css to change so that it has a parent item called ‘menu’ that when clicked displays the menu child links in a vertical list.
What is the best way to achieve this?
Should I create both types of menu and use css to switch their visibility or is there a way I can make the first menu become the new second menu?
Any help would be really appreciated. I am sure switching between hidden css property on each would work but I wasn’t sure how semantic friendly this would be etc?
Cheers
Righto, it took a bit of work but I’ve created a working example of what you’re after here
HTML
CSS
JAVASCRIPT
In summary, any time the resolution drops under 480px wide, the mobile styling will kick in. This’ll basically stack the menu items vertically and allow you to collapse/expand the nav with the open/close link. Anything larger than 480px will use the default styling which will order the menu items horizontally.
Hopefully it all makes sense 🙂