Is it possible to style search-selection in Firefox?

孤街浪徒 提交于 2019-12-11 03:37:24

问题


In Firefox, I can search for text using either

  • CTRL+F [normal search]
  • / [quick search]
  • ' [quick search, links only]

I can style user-selected text / links using

  • a:focus
  • a:active
  • ::-moz-selection

However

  • the first two seem to apply only to user-selected/focused/activated links (by mouse, or TAB-navigating).
  • ::-moz-selection seems to be applied only to the text I manually selected, not the text that is selected due to incremental search. The incremental search match is highlighted by Firefox in the greenish color.
  • when I search only in links ('), the searched part is being highlighted by Firefox in the same greenish color; moreover, the whole link gets outline; when the quick find disappears (~5 secs), the whole link gets :focus style applied -- not before that.

See the screenshot:

Is there any CSS pseudoclass to allow styling of selection that resulted from the search, not the user hand-selection?


回答1:


From this mozillazine forum post, you can go to about:config and add one of the following to style different ui.text* settings on the browser chrome:

ui.textSelectBackground
ui.textSelectBackgroundAttention
ui.textSelectBackgroundDisabled
ui.textSelectForeground
ui.textBackground
ui.textForeground
ui.textHighlightBackground
ui.textHighlightForeground


来源:https://stackoverflow.com/questions/11592040/is-it-possible-to-style-search-selection-in-firefox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!