How to set css to be non-clickable

coldplay.xixi
Release: 2023-01-05 16:12:55
Original
2653 people have browsed it

The way to set non-clickable CSS is to use [pointer-events: none;] to disable mouse events. Events bound by other methods will still be triggered, such as keyboard events.

How to set css to be non-clickable

The operating environment of this tutorial: windows7 system, css3 version, DELL G3 computer.

How to set non-clickable css:

css code:

.disable {
pointer-events: none;
}
Copy after login

Example:

const disabled = true;
<Button className={disabled ? &#39;disabled&#39; : null}>点击</Button><style>
  .disabled {
      pointer-events: none;
      // 设置pointer-events: none;再设置cursor是没有效果的
  }</style>
Copy after login

Rendering:

How to set css to be non-clickable

Note:

  • When the value of pointer-events is none, if the element is absolutely positioned, the element below it can Selected.

  • pointer-events: none; It is only used to disable mouse events. Events bound by other methods will still be triggered, such as keyboard events, etc.

  • If the pointer-events of a child element of an element is set to another value (for example: auto), then when the child element is clicked, the parent element will still be triggered by event bubbling. event.

Recommended related tutorials: CSS video tutorial

The above is the detailed content of How to set css to be non-clickable. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
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
Popular Tutorials
More>
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!