Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use user-select in CSS

Shulou Source: shulou.com Published: 2022-06-01 12:18:18 09月20日 Update

This article mainly introduces how to use user-select in CSS. It is very detailed and has a certain reference value. Friends who are interested must finish it!

The user-select property is a new property added by css3 and is used to set whether users can select Chinese text.

Grammar.

User-select:none | text | all | element

Default value: text

Scope of application: all elements except replacement elements

Value description

None: text cannot be selected

Text: you can select text

All: can be selected when all content as a whole. If you double-click or click a child element in the context, the selected section will be the highest ancestor element backtracking with that child element.

Element: text can be selected, but the selection range is constrained by element boundaries

Description

1. IE6-9 does not support this attribute, but supports the use of the tag attribute onselectstart= "returnfalse;" to achieve the user-select:none effect; Safari and Chrome also support this tag attribute

2. This attribute is still not supported until Opera12.5, but like IE6-9, the private tag attribute unselectable= "on" is also supported to achieve the user-select:none effect; another value of unselectable is off.

3. In addition to Chrome and * Safari, in other browsers, if the text is set to-ms-user-select:none;, users will not be able to start selecting text in the text block. However, if the user starts selecting text in other areas of the page, the user can still continue to select the area text that sets the text to-ms-user-select:none;*

4. The corresponding script feature is userSelect.

Example:

Css Code:

.box {

-webkit-user-select:none

-moz-user-select:none

-ms-user-select:none

User-select:none

}

Html Code:

This is the test data.

The above is all the contents of the article "how to use user-select in CSS". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Text selection attributes elements support users content tags code regions effects articles scope highest upper and lower context value interests guys buddies Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Tech Info macOS Apple NVidia