问题
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