问题
The font between the <option>
tags cannot be changed with CSS in FireFox. (It can be done, using normal CSS statements, in Chrome.) I can change the font for the <select>
part of the statement using CSS, so that the selected option appears in my desired font, but the text between the <option>
tags in the dropdown list are always in FireFox's default font. This is important because I want to use a monospace font in the option tags.
Can I gain control over style of the font in the <option>
tag in FireFox?
My clients are telling me they used to see the monospace font in a dropdown select list in FireFox - until a few weeks ago. Did FireFox change the way they render a directive to change the font using CSS in the <option>
and <select>
tags? Does anyone know?
I have read that "the standard" does not specify that the contents between the option tags must be stylable - but that some browsers, like Chrome, render the CSS anyway, while FireFox does not.
回答1:
The question has not been answered. It seems impossible to change the font of the
<option>content</option>
text between the option tags in FireFox. It does work in Chrome.
回答2:
As of Firefox 52, you are now able to style the content in the option tag:
<option>content</option>
You can test it out on JS Bin.
So far, I've tested color, font family, font style, and size.
Both inline styles and stylesheet declarations now work on Firefox.
回答3:
It is not a duplicate because it appears after last FireFox update (now v52.0 x32), before the update FF showed text in OPTION with correct styles of font.
UPD: In single process window mode styles of font in OPTION are showing right, in multi process mode are not. To switch on/off multi process mode type about:config in address line and find option "browser.tabs.remote.autostart"
回答4:
The font-family between the tags cannot be changed with CSS in Firefox so you can best use this plugin converts the select tag into span so we can apply font-family on span. and it gives you default search bar if you need.
plugin link- https://select2.org/
来源:https://stackoverflow.com/questions/39515909/style-the-font-for-select-and-option-tags-in-firefox-mozilla