Making a standard horizontal nav menu that can also collapse to a toggle-able mobile side menu is one of those things that just exposes how CSS is truly the most tedious, horribly-designed thing in the history of computing.
I started trying to learn how to do this by following tutorials and a copying a lot of big websites that had visually attractive designs and in the end every single one is actually full of bugs, has no accessibility, or requires a brittle pile of 12+ different CSS directives that collapse if they're not all put together perfectly.
Through looking at these big sites, I have realized a lot of them write two completely different nav bars and just hide one when you swap to a mobile view. This helps a bit, but the fixed/absolute positioning crap you have to do to float things for the mobile-style menus is still hideous heap of hacks.