Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How css does not allow page content to be copied

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to prevent css from copying page content". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "css how not to copy page content" bar!

In css, you can use the "user-select" attribute to achieve the effect that the content of the page cannot be copied. This attribute is used to specify whether the content of the element can be selected. When the value of the attribute is "none", the content of the element will not be selected and will not be copied. The syntax is "element {user-select:none;}".

The operating environment of this tutorial: windows10 system, CSS3&&HTML5 version, Dell G3 computer.

How to prevent css from copying page content

In css, to achieve the effect of not being able to copy page content, you can use the user-select attribute.

The user-select attribute specifies whether the text of the element can be selected. In a web browser, if you double-click on the text, the text is selected or highlighted. This property is used to prevent this behavior.

The syntax is as follows:

User-select: auto | none | text | all

The meaning of the attribute value is as follows:

Among them, it should be noted that:

-moz-user-select:none; / * Firefox private attribute * /-webkit-user-select:none; / * WebKit kernel private attribute * /-ms-user-select:none; / * IE private attribute (IE10 and beyond) * /-khtml-user-select:none; / * KHTML kernel private attribute * /-Opera user Mutual select user-select:none; / * Opera private attribute * / kernel / * CSS3 attribute * /

Examples are as follows:

Body {- webkit-user-select: none; / * Safari * /-ms-user-select: none; / * IE 10 and IE 11 * / user-select: none; / * Standard syntax * /} user-select attribute adds the user-select attribute to the body element of the page, so that the page content can not be copied.

Output result:

The text output in the above example can no longer be copied.

At this point, I believe that everyone on the "css how not to copy page content" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report