I’m unclear what the problem is.
What is happening that should not or what is not happening that should?
I see the menu you display and it changes when the window is shortened
and expands when the window lengthens. How is that wrong?
Yes I got the menu to shorten but it doesn’t work well on mobile devices.
When you click on “Overview” and the child elements appear they appear over top of the first level.
I would like when you click on “Overview” it opens up the child elements and pushes the other ones down. Like an accordion dropdown menu on mobile devices.
I can’t seem to get it to work properly. Plus on my iPhone when I click on Overview it takes me back to top of the page so there are a few things I’m most likely missing.
Ok I edited this and put it in and have a couple issues on Desktop…
When you roll over “Overview” it pushes all content down. Is it possible to not do this so the dropdown menu shows overtop of the image on Desktop only.
When you roll over “Overview” it expands the li to the width of the longest child li hence pushing all that parent li’s over. Not ideal
When rolling over “Overview” the dark blue expands, across 100% of the width below as well, I don’t want it to show below the parent.
Hope, that makes sense, on mobile it works perfect!
So once can resolve this I can build rest of the navigation as their will be child li’s under each parent nav item.
Ok I edited this and put it in and have a couple issues on Desktop…
I’m not much of a mind-reader so I have difficulty helping on things I don’t understand.
What is “this”?
What are the starting conditions of the problem?
What is clicked or rolled over to recreate the problem?
Which browser are you using?
Thanks for this but is it possible to use the html with ul and li that is currently in there as that is using the default Wordpress Menu so can’t really introduce divs.
I have no idea. I do not use a Wordpress Menu, whatever that is.
My guess is that you should be able to use additional UL/LI with other CSS statements or classes as JS is just JS and CSS is just CSS regardless of what you wrap around it.
Dropdown menus are inherently difficult to do properly and should be avoided if at all possible. There are issues with touch devices (because they don’t hover properly) and issues with accessibility as keyboard navigation is not possible.
If you must have a dropdown then consider a click js driven dropdown which will work for both desktop and mobile and also have keyboard interactivity.
How do you define desktop and what is unique with a desktop that you can target?
The problem is that there is no '‘target-able’ distinction between mobile and desktop apart from media queries based on screen sizes which again is just a best guess because ipads are very large now (larger than some laptops) and behave like mobile devices with touch enabled.
Therefore the best approach is to use the method that works for all which is a click dropdown rather than a hover dropdown. You can detect touch with js and offer click dropdowns to touch and hover to non-touch but requires a does of js to do this.Or you can change effects based on screen width but obviously not as effective as detecting touch.
The other issue I see is that you are allowing the menu to wrap around at smaller screen widths and a hover menu that wraps is also an awkward construct and not pleasing to the eye.
Not to mention that hover dropdowns are hard to use for those who are motor impaired and as you haven’t built in keyboard accessibility it becomes a nightmare to use
Having said all that and if you still want to continue a quick fix is to absolutely place the dropdowns on larger screen sizes.
e.g. Do this:
@media screen and (min-width:641px){
#menu-annular-tear ul.sub-menu{position:absolute;}
.sub-conditions{position:relative}
.subnavigation li:hover> a{background:#1194d6}
.subnavigation .sub-menu li > a:hover{background:#003a58}
}
One other thing I noticed now after putting in that code my main top navigation in the header doesn’t work on mobile properly anymore it like cuts off several of the nav items.
Thanks @PaulOB greatly appreciate it. Not sure what happened. Was working earlier yesterday then wasn’t
EDIT: I resolved it, I put a z-index on it as the other nav which you helped me with was showing above the dropdown menu. So just got to work on the z-index’s and put them in right orders and I’ll be good.