CSS Block text selection

Source: Internet
Author: User

In daily use, often encountered click button/menu when the text is selected, in order to avoid this situation, you can use the pure CSS to solve the problem (ie10+), for the old version can only use Js:onselectstart = ' return false; ' This way. Here's a look at-prefix-user-select:
Formal Syntax:none | Text | All |  Element (-prefix-) User-select:none;  All are not selectable (-prefix-) User-select:text;  Allow text selection (-prefix-) User-select:all; In an HTML editor, if a double-click or Context-click occurred in sub-elements, the highest ancestor with this value wil L be selected.  (-prefix-) user-select:element; Only IE FF support, ignoring ...

Note that this property does not belong to the standard!
Currently the main use is none & Text
The structure is assumed as follows:
<Body>    <nav>        <DT>Level 1</DT>    </nav>        <P>Xxxxxxxxxxxxxxxxxxxx</P></Body>    

The CSS is as follows:

Body {    -webkit-user-select: none;}     nav dt{    -webkit-user-select: text;}

The result is: The text of the P tag cannot be selected, and the DT text will be selected normally.

  

CSS Block text selection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.