How can I disable highlighting in html or JS?

后端 未结 7 1938
太阳男子
太阳男子 2020-12-13 19:24

I need to disable the highlighting of selected text on my web app. I have a good reason for doing this and know that this is generally a bad idea. But I need to do it anyway

7条回答
  •  佛祖请我去吃肉
    2020-12-13 20:13

    You can use the CSS pseudo class selector ::selection and ::-moz-selection for Firefox.

    For example:

    ::-moz-selection {
        background-color: transparent;
        color: #000;
    }
    
    ::selection {
        background-color: transparent;
        color: #000;
    }
    
    .myclass::-moz-selection,
    .myclass::selection { ... }
    

提交回复
热议问题