Hover how to trigger on a mobile browser

Source: Internet
Author: User

For example the HTML structure is as follows

<div>menu
<ul> <li>item1</li > <li>item2</li> </ ul >
</div>

Css

{    display:block;}

As in the code, when the mouse hovers over the menu, the UL is displayed, but because the mobile browser does not have a mouse, the hover in the CSS cannot be triggered.

WORKAROUND: You can use a click to trigger hover

<Divonclick= "javascript:void (0)">Menu<ul>    <Li>Item1</Li>    <Li>Item2</Li></ul></Div>

To the DIV plus onclick event, click on the menu, it will trigger hover, display ul. However, this will cause the menu has been hover state, then how to leave the hover state?

It is also very simple to add an onclick event outside of the menu, and when you click outside the menu, the menu leaves the hover state.

<onclick= "javascript:void (0)">  ... </ Body >

Hover how to trigger on a mobile browser

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.