Fixed matte background under iOS cannot be monitored dynamically, workaround

Source: Internet
Author: User

Scene: When you want to pop up a fixed dialog box (which is a popup box), and add a mask layer to the background, you want to click the mask layer to close the entire pop-up box when you're done.
The mask layer of the conditional 1:fixed is created dynamically and cannot be monitored using the Click event
Condition 2: There are links or elements that cannot be clicked under the mask (or there are actions or links to jump, etc.)

For condition 1, use jquery's on to listen to the entire document, and then perform the appropriate action when bubbling over the specified element

For condition 2, using Touchstart/touchend, a point-through problem is created

My experience and solutions:

1. Use jquery's delegate method to monitor the Click event

2, the use of advice from StackOverflow

On IOS There is no event bubbling without a cursor style. Your CSS need to add cursor:pointer; to the element.

Therefore, the final solution is to use delegate to dynamically listen for click events and add styles to the mask layer Cursor:pointer

If you do not want a black layer when clicked, the global setting *{-webkit-tap-highlight-color:rgba (0,0,0,0) "*" represents the element that you do not want the shadow layer to appear on.

Fixed matte background under iOS cannot be monitored dynamically, workaround

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.