首页 > Web开发 > 详细

CSS禁用选中文字

时间:2020-07-17 18:09:44      阅读:56      评论:0      收藏:0      [点我收藏+]

通过CSS属性,禁用选中文字

效果预览

技术分享图片

CSS

.no-select {
/* iOS Safari */
-webkit-touch-callout: none;
/* Chrome/Safari/Opera */
-webkit-user-select: none;
/* Konqueror */
-khtml-user-select: none;
/* Firefox */
-moz-user-select: none;
/* Internet Explorer/Edge */
-ms-user-select: none;
/* Non-prefixed version, currently not supported by any browser */
user-select: none;
}

HTML测试

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CSS禁用选中文字</title>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <style type="text/css">
        .no-select {
            /* iOS Safari */
            -webkit-touch-callout: none;
            /* Chrome/Safari/Opera */
            -webkit-user-select: none;
            /* Konqueror */
            -khtml-user-select: none;
            /* Firefox */
            -moz-user-select: none;
            /* Internet Explorer/Edge */
            -ms-user-select: none;
            /* Non-prefixed version, currently not supported by any browser */
            user-select: none;
        }
    </style>
</head>
<body>
<div style="text-align: center;top: 200px;">
    <h1>可以选择</h1>
    <h1 class="no-select">不可以选择</h1>
</div>
</body>
</html>

CSS禁用选中文字

原文:https://www.cnblogs.com/ast935478677/p/13331060.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!