如何更改 unicode 字符的颜色

Ash*_*son 7 unicode

我试图得到一个像这样的绿色、青色、紫色和黄色的大圆圈: ,但没有任何代码。有什么办法可以通过更改代码来更改颜色吗?

小智 20

不。颜色是字符固有的 - 还有一个大蓝色圆圈 (U+1F535 - ),但 Unicode 标准当前没有定义其他颜色。

  • ... (21认同)

Ali*_*426 18

如果使用 HTML,您可以附加 xFE0E 来获取使用 CSS 的文本版本和颜色:

<span>&#x1f534;</span>
<span>&#x1f534;&#xfe0e;</span>
<span style="color: lime;">&#x1f534;&#xfe0e;</span>
Run Code Online (Sandbox Code Playgroud)

  • 我在问题中没有看到 HTML/CSS/web 的提及。我错过了什么? (3认同)
  • 不,你没有错过任何东西。 (2认同)

ntg*_*ntg 12

Unicode 非常庞大,甚至有克林贡语,现在它有更多的颜色,甚至还有笑脸...在这里,更改数字来搜索并找到您需要的内容...

for i in range (10):
    ii = int('0x1f7e0',base=16)+i
    print('{:>15}'.format('[{}: {}] '.format(hex(ii),chr(ii))),end='')
    if i%7==6:
        print()
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

对于青色圆圈,尝试从 0x1f7df 开始,范围为 1000...另请注意,unicode 颜色是尽力而为,因此例如在克林贡浏览器上,内容可能不会以颜色显示...

另外,要查找您拥有的字符代码,例如:

chars=''
for i,c in enumerate(chars):
    print('[{}: {}] '.format(hex(ord(c)),c), end='')
    if i%7==6:
        print()
Run Code Online (Sandbox Code Playgroud)

给出:

[0x1f535: ] [0x1f534: ] [0x1f7e0: ] [0x1f7e1: ] [0x1f7e2: ] [0x1f7e3: ] [0x1f7e4: ] 
[0x1f7e6: ] [0x1f7e5: ] [0x1f7e7: ] [0x1f7e8: ] [0x1f7e9: ] [0x1f7ea: ] [0x1f7eb: ] 
[0x1f6d1: ] [0x1f536: ] [0x1f537: ] [0x1f538: ] [0x1f539: ] [0x1f53a: ] [0x1f53b: ]
Run Code Online (Sandbox Code Playgroud)


Mau*_*iri 6

在 HTML 和 CSS 中,您可以附加 xFE0E 来获取文本版本和颜色:

在 HTML 中:

<div>&#x274c;</div>
<div style= "color: blue;">&#x274c;&#xfe0e;</div>
<div style= "color: green;">&#x274c;&#xfe0e;</div>
Run Code Online (Sandbox Code Playgroud)

在CSS中:

.css-symbol:after {
  color: black;
  content: "\274C";
}

.css-symbol1:after {
  color: black;
  content: "\274C\fe0e";
}

.css-symbol2:after {
  color: blue;
  content: "\274C\fe0e";
}
Run Code Online (Sandbox Code Playgroud)
<div class="css-symbol">css:&nbsp;</div>

<div class="css-symbol1">css:&nbsp;</div>
<div class="css-symbol2">css:&nbsp;</div>
Run Code Online (Sandbox Code Playgroud)

混合 HTML 和 CSS:

div {
  color: black;
}


.css-symbol:after {
  color: blue;
  content: "\274C\fe0e";
}
Run Code Online (Sandbox Code Playgroud)
<div>&#x274c;</div>
<div>&#x274c;&#xfe0e;</div>
<div class="css-symbol"></div>
Run Code Online (Sandbox Code Playgroud)