Forum Moderators: Robert Charlton & goodroi
There are different ways of making dropdown menus. The pure-CSS method (no javascript) looks something like this, off the top of my head.
:: detour to look up analogous code of my own, because "off the top of my head" turns out to be an overstatement ::
CSS:
ul.dropmenu li {display: inline-block;}
ul.dropmenu ul {display: none;}
ul.dropmenu li:hover ul {display: block;}
HTML:
<ul class = "dropmenu">
<li>Good Stuff
<ul>
<li>Hidden 1</li>
<li>Hidden 2</li>
<li>Hidden 3</li>
</ul>
</li>
<li>Better Stuff
<ul>
<li>Hidden 1</li>
<li>Hidden 2</li>
<li>Hidden 3</li>
</ul>
</li>
</ul>
Did you catch the
ul.dropmenu li:hover ul
?
That's the magic that makes it all work. Things preceded by a colon are called "pseudo-classes" [w3.org]. This particular one means, reading from right to left:
"This style applies to an unordered list (ul)
that's inside of a list item (li)
which the user is currently hovering on (:hover)
when the whole thing is inside an unordered list of class 'dropmenu' (ul.dropmenu)"
mobile does not support hover mostly
But mobile does not support hover mostly.
but currently use a breadcrumb menu, combined with a mouseover (hover) JS drop-down menu where the script is in a folder that is blocked in robots.txt.
This stops spiders from having to trawl through a big on-page script, or from seeing a massive collection of links (...)