Home  >  Article  >  Web Front-end  >  How to prevent css images from being selected

How to prevent css images from being selected

藏色散人
藏色散人Original
2020-12-31 09:51:045471browse

Css method to prevent images from being selected: First open the corresponding css code file; then use the "pointer-events" attribute in css to set the image to prevent selection, with statements such as "img {pointer-events: none;}".

How to prevent css images from being selected

#The operating environment of this tutorial: Dell G3 computer, Windows 7 system, css3 version.

You can use the pointer-events attribute in css to set the image not to be selected.

The pointer-events attribute specifies under what circumstances (if any) a specific graphic element can be the target of a mouse event. A value of none means that the mouse event "penetrates" the element and specifies anything "below" the element. This means that the element cannot be selected.

The css code is as follows:

img {
pointer-events: none;
}

none: The element will never become the target of mouse events. However, mouse events can be directed to descendant elements when their pointer-events attribute specifies a different value, in which case the mouse event will trigger the parent element's event listener during the capture or bubbling phase.

Recommended: "css video tutorial"

The above is the detailed content of How to prevent css images from being selected. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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