user-select有两个值:

none:用户不能选择文本

text:用户可以选择文本

需要注意的是:user-select并不是一个W3C的CSS标准属性,浏览器支持的不完整,需要对每种浏览器进行调整

<style>
    body{
        -moz-user-select: none;             /*火狐*/
        -webkit-user-select: none;          /*webkit浏览器*/
        -ms-user-select: none;              /*IE10*/
        -khtml-user-select: none;           /*早期浏览器*/
        user-select: none;
    }
    /*IE6-9还没发现相关的CSS属性*/
    /*IE6-9*/
    document.body.onselectstart = document.body.ondrag = function(){
        return false;
    }
</style>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-30
  • 2022-01-24
  • 2022-12-23
  • 2021-09-27
  • 2022-12-23
  • 2022-01-18
猜你喜欢
  • 2021-10-07
  • 2021-11-12
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2022-12-23
相关资源
相似解决方案