Mobile devices use touch screen, which reacts only to touch, so there is no hover.
Systems vary, on some a first touch is considered a hover and the second a click, but on many a touch is a click.
You cannot rely on hover for mobile devices.
Also, I’m not sure about your selectors, without seeing the html.
With that corrected, it appears to work, though I don’t have access to an actual mobile at present. But I would think a tap on the icon would open the menu. These are usually a problem for mobiles when the hover icon is a link too, not the case here.
Hi Sam. It indeed works on latptop with adjusted screen but on both my iphone and sony experia it isn’t working. Do you have any other suggestions maybe?
It’s hard to say without having anything to test it with. From trying the code, it works as expected on the desktop.
FWIW the way I do this kind of thing is more like this and appears to work on touch screen:-
Instead of hiding off-screen. Not that it should make a difference.
.mb-menu li:hover ul {
display: block;
}
Also, do you need hover, focus and active? Just hover should do it, only mouse users will hover and touch screen users will have to tap to open the menu.
Another thought, does the element need to be wrapped in an <a> for hover to work? I thought it did, though it evidently does work on desktop. I normally do it that way, with an <a>.
@ Sam. I know some people advocate to use the display none rather than to use the negative margins. For me sofar it always worked though
@bedakb I use min-with instead of min-device-width but yes that is how the media query indeed looks like. Here is the link to the website. Hope yo can see where things are going wrong
However, generally you would not do this on hover but add a toggle with js to do it on click just to make sure mobiles can open and close the menu if needed. At the moment a first touch will open the menu but then there is no way to close the menu on touch devices.
It’s much better to implement a click menu for the small screen version. You can do this easily with some js to toggle a class on the element when clicked. It can be done in CSS with the checkbox hack but I believe there are issues in some android devices with the checkbox hack.