html怎么禁止复制粘贴
时间:2022-02-11 16:29
在html中,可以利用touch-callout和user-select属性来属性禁止复制粘贴功能,只需要设置“user-select:none;-webkit-touch-callout:none;”样式即可。 本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。 小伙伴们在开发的时候偶尔会遇到这样的需求,客户要求文章页禁止复制和粘贴,实现这个功能代码如下 (可同时实现PC端和手机端): 在添加完这段代码后,在IOS 上会有问题的,这个时候你会发现input 框无法正在输入了内容了;造成这个原因就是 -webkit-user-select:none; 这个属性造成的。 解决这个方法 就是 在css 文件中同时设置一下input 的属性,如下所示: 推荐教程:《html视频教程》 以上就是html怎么禁止复制粘贴的详细内容,更多请关注gxlsystem.com其它相关文章!*{
-webkit-touch-callout:none; /*系统默认菜单被禁用*/
-webkit-user-select:none; /*webkit浏览器*/
-khtml-user-select:none; /*早期浏览器*/
-moz-user-select:none;/*火狐*/
-ms-user-select:none; /*IE10*/
user-select:none;
}
input {
-webkit-user-select:auto; /*webkit浏览器*/
}