• CSS -- 禁止用户选择


    CSS -- 禁止用户选择

    网站会有一些简单的保密需求,不想让用户复制文字,或者轮播图到头了,左右箭头还在点点点,会有蓝色的背景,使用下面的css就可以解决这种问题。

    CSS

    /* 禁止长按保存图片 */
    img {
      pointer-events:none;
    }
    /* 禁止复制文本 */
    *:not(input,textarea){
      -webkit-touch-callout: none; /* iOS Safari */
      -webkit-user-select: none; /* Chrome/Safari/Opera */
      -khtml-user-select: none; /* Konqueror */
      -moz-user-select: none; /* Firefox */
      -ms-user-select: none; /* Internet Explorer/Edge */
      user-select: none; /* Non-prefixed version, currently not supported by any browser */
    }
    .select-none {
      -webkit-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none
    }
    .select-text {
      -webkit-user-select: text;
      -moz-user-select: text;
      -ms-user-select: text;
      user-select: text
    }
    .select-all {
      -webkit-user-select: all;
      -moz-user-select: all;
      -ms-user-select: all;
      user-select: all
    }
    .select-auto {
      -webkit-user-select: auto;
      -moz-user-select: auto;
      -ms-user-select: auto;
      user-select: auto
    }
    

    js(兼容IE6-9)

    document.body.onselectstart=document.body.ondrag=function(){
      return false;
    }
    document.addEventListener('contextmenu', function(e){
      e.preventDefault(); // 阻止默认右键菜单行为
    })
    document.addEventListener('selectstart', function(e){
      e.preventDefault(); 
    })
    
  • 相关阅读:
    转贴ARM NEON 优化的例子
    GP(General-purpose Processor)与DSP的存储器结构区别
    arm中的饱和指令
    MIPS,MCPS, MHz for voice codec
    免费提供万方论文
    ARM CORTEX Ax NEON 中的加法指令
    android C编程技巧 及 C/C++开发测试(转)
    SQL Server 存储过程的经典分页 GO
    详细设计说明书大纲 GO
    正则表达式介绍 GO
  • 原文地址:https://www.cnblogs.com/lisaShare/p/14393899.html
Copyright © 2020-2023  润新知