CSS settings page content cannot be selected

When browsing the web, you will encounter some text you want to copy that cannot be selected

If we want to achieve this effect, we only need to set a css for the label containing this part of the text Attribute

user-select:none

But the lower version of IE browser is invalid. To achieve this effect, you can use the tag attribute onselectstart="return false;"< /code>to achieve

 <div class="test">

You can't get me
div>

 .test {

user-select: none
}

Write this way, the text displayed on the page cannot be selected

In order to use multiple browsers, you can write like this, But IE also needs to implement inline attributes

 .test {

-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}

 <div class="test">

You can't get me
div>

 .test {

user-select: none
}

 .test {

-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}

Leave a Comment

Your email address will not be published.