Sharing tips on using the pointer-events property of CSS to achieve mouse penetration effects

高洛峰
Release: 2017-03-08 14:18:16
Original
1885 people have browsed it

The scope of responsibilities of CSS and JavaScript in modern browsers are becoming increasingly blurred. For example, the -webkit-touch-callout attribute in CSS can prevent the bubble box from popping up when the user clicks on it in iOS. The style of pointer-events to be discussed in this article is more like JavaScript. It can:

1. Prevent the user’s click action from producing any effect
2. Prevent the display of the default mouse pointer
3. Prevent hover and active state changes in CSS from triggering events
4. Prevent events from being triggered by JavaScript click actions
One CSS property can do so many things!

When using pointer-events:none, it means that it will not capture any clicks, but will just let the event penetrate below it. The code is as follows:

 

Copy after login

If the value is auto, the effect is the same as if the pointer-events attribute is not defined, and the mouse will not penetrate the current layer. In SVG, this value has the same effect as visiblePainted.
This pointer-events attribute has many attribute values that can be used, but most of them are for SVG: auto, none, visiblePainted*, visibleFill*, visibleStroke*, visible*, painted*, fill*, stroke*, all*, and inherit.

Some things to note about pointer-events:
1. Child elements can declare pointer-events to unlock the mouse event blocking restriction of the parent element.
2. If you set a click event listener for an element, and then you remove the pointer-events style declaration, or change its value to auto, the listener will take effect again. Basically, the listener will respect the pointer-events settings.


The above is the detailed content of Sharing tips on using the pointer-events property of CSS to achieve mouse penetration effects. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!