Home  >  Article  >  Web Front-end  >  How to prohibit copying in css

How to prohibit copying in css

coldplay.xixi
coldplay.xixiOriginal
2021-04-30 17:01:066786browse

The way to prohibit copying of css is to set non-copyable css code through the [user-select] attribute, the syntax is [user-select: none | text | all | element].

How to prohibit copying in css

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

How to prohibit copying in css:

Set non-copyable css code through the user-select attribute:

    -moz-user-select:none; /* Firefox私有属性 */
    -webkit-user-select:none; /* WebKit内核私有属性 */
    -ms-user-select:none; /* IE私有属性(IE10及以后) */
    -khtml-user-select:none; /* KHTML内核私有属性 */
    -o-user-select:none; /* Opera私有属性 */
    user-select:none; /* CSS3属性 */

IE6-9 does not support this attribute , but supports using the label attribute onselectstart="return false;" to achieve the effect of user-select:none.

user-select

Syntax:

user-select:none |text| all | element

Default value: text

Applies to: except Replace all elements except the element

Inheritance: None

Animation: No

Calculated value: Specified value

Value:

none: Text cannot be selected

text: Text can be selected

all: All content can be selected when taken as a whole. If you double-click or contextually click on a child element, the selected part will be the highest ancestor element tracing back from that child element.

element: Text can be selected, but the selection range is constrained by the element boundary

Related learning recommendations: css tutorial

The above is the detailed content of How to prohibit copying in css. 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