美文网首页
阻止页面元素被选中

阻止页面元素被选中

作者: 小哼唧麻 | 来源:发表于2020-05-06 16:25 被阅读0次

    【问题】
    侧导航栏点击过快,会导致父导航栏及子导航栏均被选中。

    【解决】

    • css
      在父元素中添加user-select: none;
    -moz-user-select:none;/*火狐*/
    -webkit-user-select:none;/*webkit浏览器*/
    -ms-user-select:none;/*IE10*/
    -khtml-user-select:none;/*早期浏览器*/
     user-select:none;
    
    • 在相应父元素上添加 onselectstart="return false;"
    <ul onselectstart="return false;"></ul>
    

    【参考】

    相关文章

      网友评论

          本文标题:阻止页面元素被选中

          本文链接:https://www.haomeiwen.com/subject/fipwghtx.html