Make HTML content not react on search (Ctrl+F)

后端 未结 7 2182
春和景丽
春和景丽 2021-01-01 07:12

In my web app I have a layer with a static HTML content that displays a text.

When I do a search on a page (ctrl+F) and type some text that is contained in the layer

7条回答
  •  梦谈多话
    2021-01-01 07:51

    If all you want is for the highlighted text to be the same color as the surrounding text, you can change the highlight color in many browsers. Assuming the normal text is black on white,

    ::-moz-selection {
      background: white;
      color: black;
    }
    ::-webkit-selection {
      background: white;
      color: black;
    }​
    ::selection {
      background: white;
      color: black;
    }
    

    will hide the highlight, while keeping the normal select-functionality.

    See also Changing the text selection color using CSS?

提交回复
热议问题