I've got the following problem with a menu on a responive website:
I created a html menu which has ul
/li
-structure which contains links as category-names
<ul>
<li>
<a href="linkToCat">maincat1</a>
<ul>
<li>
<a href="linkToCat">subcat1.1</a>
<ul>
//deeper category stucture
</ul>
</li>
</ul>
</li>
<li>
<a href="linkToCat">maincat2</a>
<ul>
<li>
<a href="linkToCat">subcat2.1</a>
</li>
<li>
<a href="linkToCat">subcat2.2</a>
</li>
</ul>
</li>
</ul>
<style>
li > ul {
display:none;
}
li:hover > ul {
display:block;
}
</style>
I am only showing the maincats at the beginning and the the subcats open on hover as shown in this JSFiddle.
Everything just works fine on desktop. The problem is that it doesnt work on touch-devices (e.g. smartphones/tablets) as soon as I use links as the names of the categories (Which I need to do).
Is there any way to make a menu that works with hover on desktop and that is still useable on touch-devices when using links as categorynames?
I got no problem about using JavaScript or jQuery to solve this problem. Normally I am using a responsive design with a extram menu for smartphones or other mobile devices. Therefor I am using @media screen
. This sadly doesn't work with all touch devices like for example bigger tablets like some iPads or the microsoft surface.
Thank you for your answers and hints.
Edit:
The problem is the <a href>
The link always get triggert and so the menu doesn't open when i click on a category.
I now also have added links to the categorynames in the JSFiddle