HTML/CSS How to prevent highlighting text from spanning entire width of page in google chrome

前端 未结 4 2092
孤街浪徒
孤街浪徒 2021-01-05 22:59

Basically when I use Google chrome and highlight text on some websites, the highlight spans the entire width of the browser rather than just highlighting the text. How can C

4条回答
  •  [愿得一人]
    2021-01-05 23:28

    You can't alter the machanism of the highlighting algorithm. The highlight spans through paddings and margins, which is annoying sometimes. What you could do is prevent any text selection with CSS

    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -o-user-select: none;
    user-select: none;
    

提交回复
热议问题