Home Web Front-end CSS Tutorial How to use the pointer-events property of CSS to achieve mouse penetration effect

How to use the pointer-events property of CSS to achieve mouse penetration effect

Jun 20, 2018 pm 02:44 PM
css mouse

This article mainly introduces how to use the pointer-events attribute of CSS to achieve the mouse penetration effect. It has a certain reference value. Now I share it with you. Friends in need can refer to it.

When pointer After the value of -events is set to none, the browser will not obtain the click event of the mouse on the layer at the current position, causing the effect of mouse penetration! Let's explain the implementation using the pointer-events attribute of CSS. The magical technique of mouse penetration effect

The scope of responsibilities of CSS and JavaScript in modern browsers are becoming increasingly blurred and unclear. 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 CSS Changes in hover and active states trigger events
4. Prevent JavaScript click actions from triggering events
One CSS property can do all of 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:

<style>   
 .overlay {   
  pointer-events: none;   
 }   
</style>   
<p id="overlay" class="overlay"></p>
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 entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

About how to use the table-cell attribute in CSS

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

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Razer | Pokémon Gengar wireless mouse and mouse pad are now available, with a set price of 1,549 yuan Razer | Pokémon Gengar wireless mouse and mouse pad are now available, with a set price of 1,549 yuan Jul 19, 2024 am 04:17 AM

Razer | Pokémon Gengar wireless mouse and mouse pad are now available, with a set price of 1,549 yuan

VGN co-branded 'Elden's Circle' keyboard and mouse series products are now on the shelves: Lani / Faded One custom theme, starting from 99 yuan VGN co-branded 'Elden's Circle' keyboard and mouse series products are now on the shelves: Lani / Faded One custom theme, starting from 99 yuan Aug 12, 2024 pm 10:45 PM

VGN co-branded 'Elden's Circle' keyboard and mouse series products are now on the shelves: Lani / Faded One custom theme, starting from 99 yuan

What does placeholder mean in vue What does placeholder mean in vue May 07, 2024 am 09:57 AM

What does placeholder mean in vue

What does span mean in js What does span mean in js May 06, 2024 am 11:42 AM

What does span mean in js

What does rem mean in js What does rem mean in js May 06, 2024 am 11:30 AM

What does rem mean in js

How to introduce images into vue How to introduce images into vue May 02, 2024 pm 10:48 PM

How to introduce images into vue

What language is the browser plug-in written in? What language is the browser plug-in written in? May 08, 2024 pm 09:36 PM

What language is the browser plug-in written in?

What is node in js What is node in js May 07, 2024 pm 09:06 PM

What is node in js

See all articles