可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
It's possible to include Emoji characters in modern browsers, but how can one make it a single color and choose that color?
For example, here is some Emoji and some regular (plane 0) Unicode symbols. All should be red, but only the symbols are rendered in red.

Associated HTML + CSS:
回答1:
Yes, you can color them!
div { color: transparent; text-shadow: 0 0 0 red; }
<div>???</div>
回答2:
Not every emoji works the same. Some are old textual symbols that now have an (optional or default) colorful representation, others were explicitly (only) as emojis. That means, some Unicode codepoints should have two possible representations, text
and emoji
. Authors and users should be able to express their preference for one or the other. This is currently done with otherwise invisible variation selectors U+FE0E (text
, VS-15) and U+FE0F (emoji
, VS-16), but higher-level solutions (e.g. for CSS) have been proposed.
The text-style emojis are monochromatic and should be displayed in the foreground color, i.e. currentcolor
in CSS, just like any other glyph. The Unicode Consortium provides an overview of emojis by style (beta version). You should be able to append ︎
in HTML to select the textual variant with anything in the columns labeled “Default Text Style; has VSs” and “Default Emoji Style; has VSs”. This doesn’t include the example emojis ??? and many others, though.
I’ve added ? U+1F480 Skull and ? U+1F44C OK Hand Sign because the background should show through their “eyes” and I’ve used numeric character references just to make the code more obvious and more robust against copy-and-paste errors.
It has been proposed, however, that both variation selectors can be applied to any character, which would have no effect in most cases. Note that some vendors, especially Samsung, are already shipping (default) emoji glyphs for several other characters (goo.gl/a4yK6p
or goo.gl/DqtHcc
).
回答3:
You can fill them with a solid color:

p { font-size: 20px; color: transparent; text-shadow: 0 0 0 blue; }
<p>?</p> <p>?</p> <p>?</p>
Or you can outline them:

body { background: #fff; } p { margin: 0; color: transparent; text-shadow: 0 0 3px blue; font-size: 20px; position: relative; } p::before { content: attr(title); position: absolute; text-shadow: 0 0 0 #fff; }
<p title="?">?</p> <p title="?">?</p> <p title="?">?</p>
回答4:
As Emoji is quite new, styling it is not yet supported natively.
The workaround is to use an Emoji font such as Twitter's Twemoji. Then it can be styled much the same way Font Awesome or native Unicode can be styled.
回答5:
Some, but not all, code points can be drawn in either text form (non-picture-based glyph) or emoji form (picture-based glyph). Unicode describes that these two forms can be selected by using one of two variation selectors: either U+FE0E (VARIATION SELECTOR-15) or U+FE0F (VARIATION SELECTOR-16). When drawn in non-picture-based form, the color
CSS property should apply.
Example:
More information, along with a full list of the code points which participate in these variation sequences, can be found at http://unicode.org/emoji/charts/emoji-variants.html
(Note that different operating systems may choose a different default when the bare code point is used. For example, try viewing this post in macOS and iOS - the bare code point above looks different!)
回答6:
IF YOU NEED TO USE CSS AFTER,BEFORE PSEUDO ELEMENT YOU CAN PROCED LIKE THIS
<span class="react-thumb-fly" title="Aimé"> <button class="react-toggle-icon-thumb"></button> </span>
THEN WRITE THIS FOR CSS
.react-toggle-icon-thumb { width: 20pt; height: 20pt; font-size: 30pt; position: relative; color: gray; cursor: pointer; border: none; background: transparent; margin-left: 0px; margin-right: 8px; top: -0px; } .react-toggle-icon-thumb:before, .react-toggle-icon-thumb:after { position: absolute; top: 0; left: 0; transition: all .3s ease-out; content: "?"; font-family: fontawesome; color: transparent; text-shadow: 0 0 0 #3498db; } .react-toggle-icon-thumb:hover:before { transform: scale(1.2); animation: thumbs-up 2s linear infinite; } @keyframes thumbs-up { 25% { transform: rotate(20deg); } 50%, 100% { transform: rotate(5deg); } }