开发者

Hover for Touch Devices

I am using the followin开发者_StackOverflowg well-known CSS code to get a drop down menu on a web page.

div#menu ul ul {
    display: none;
}
div#menu ul li:hover ul {
    display: block;
}

The menu is an u-list containing another u-list. When the mouse hovers over the list item in this menu, the second u-list becomes visible. The list items are no links, just text.

This works in modern browsers. I have a javascript forge for IE6.

However, it does not work on touch devices.

On the IPad nothing happens at all, even if I press on the list item. This is probably, because the list item is not an anchor. Or maybe, I need a click event to fix that.

On the Android browser, a longer press on the list item opens the sub-menu. However, no link in the submenu can be selected.

Can anyone help me?

In case, you need details (and have the time), look at

http://www.rene-grothmann.de/musica-aliter-test/

Thanks.


div#menu ul li:hover ul needs to become div#menu ul li:active ul for it to respond on touch devices because they don't support hover states.


Try nesting your list elements like this:

<ul>
    <li><a href="#">LINK</a>
        <ul>
        <li><a href="#">LINK</a></li>
        <li><a href="#">LINK</a></li>
        <li><a href="#">LINK</a></li>
        <li><a href="#">LINK</a></li>
        </ul>
    </li>
    <li>
    more links here, if you wish.
    </li>
</ul>

There should not be a problem with the hover state. Should work fine on any device. At lest that´s how it works for me.


I think your list items should be links. You should at least try it, and se if it works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜