CSS禁止选中文字

通过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>
posted @   吃猫的鱼℘  阅读(643)  评论(0编辑  收藏  举报
编辑推荐:
· DeepSeek 解答了困扰我五年的技术问题
· 为什么说在企业级应用开发中,后端往往是效率杀手?
· 用 C# 插值字符串处理器写一个 sscanf
· Java 中堆内存和栈内存上的数据分布和特点
· 开发中对象命名的一点思考
阅读排行:
· DeepSeek 解答了困扰我五年的技术问题。时代确实变了!
· PPT革命!DeepSeek+Kimi=N小时工作5分钟完成?
· What?废柴, 还在本地部署DeepSeek吗?Are you kidding?
· DeepSeek企业级部署实战指南:从服务器选型到Dify私有化落地
· 程序员转型AI:行业分析
Document
欢迎阅读『CSS禁止选中文字』
点击右上角即可分享
微信分享提示