The html content cannot be copied, set the page content as an attribute that cannot be copied, the front end sets the website content as an uncopyable state, CSS prohibits text selection user-select attribute, and sets the text content as read-only

In development, we often encounter a requirement, that is, some page content is read-only, and some can be copied. This is also often encountered in the page. For example, some website text can be copied directly, while some need to activate the service It can be copied. This actually uses the user-select attribute of css. This is actually very simple to implement. Look at the code:

body {
    
    
  user-select: none; // 文字不能被选中,无法复制
}

After adding the above string of codes, all the content in our body will not be able to be copied. Next, let’s take a closer look at other attributes of user-select.
insert image description here
Part of the article is excerpted from: https://blog.csdn.net/weixin_43825473/article /details/103854771

Guess you like

Origin blog.csdn.net/m0_46156566/article/details/128580249