利用css3实现禁止文章内容复制
以前想禁止文章内容复制都是用js来实现的,后来发现css3中的user-select:none;
也可以实现这个功能,下面编程教程网小编给大家介绍一下代码的运用。
user-select
属性是css3规范中新增的一个功能,有兼容性问题,因此对于不同浏览器要加前缀。
禁止复制文本的写法:
-moz-user-select:none; /* Firefox私有属性 */
-webkit-user-select:none; /* WebKit内核私有属性 */
-ms-user-select:none; /* IE私有属性(IE10及以后) */
-khtml-user-select:none; /* KHTML内核私有属性 */
-o-user-select:none; /* Opera私有属性 */
user-select:none; /* CSS3属性 */
html5代码
<div onselectstart="return false;" unselectable="on">现在来复制我试试!!!</div>
以上是编程学习网小编为您介绍的“利用css3实现禁止文章内容复制”的全面内容,想了解更多关于 前端知识 内容,请继续关注编程基础学习网。