这个 ▲ 或这个 ▼ 的 HTML 字符代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6041209/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTML character codes for this ▲ or this ▼
提问by Ram
What are the HTML entity character codes for this up arrow (▲
) and its downward-facing dog version (▼
) ?
这个向上箭头 ( ▲
) 及其向下的狗版本 ( ▼
)的 HTML 实体字符代码是什么?
I've been using GIFs to represent these arrows since I don't know their codes.
我一直在使用 GIF 来表示这些箭头,因为我不知道它们的代码。
回答by Erich Horn
The Big and small black triangles facing the 4 directions can be represented thus:
面向 4 个方向的大小黑色三角形可以表示为:
▲
▲
▲
▲
▴
▴
▴
▴
▶
▶
▶
▶
▸
▸
▸
▸
►
►
►
►
▼
▼
▼
▼
▾
▾
▾
▾
◀
◀
◀
◀
◂
◂
◂
◂
◄
◄
◄
◄
回答by Joachim Sauer
- ▲ is U+25B2 BLACK UP-POINTING TRIANGLEand it's decimal character entity is
▲
- ▼ is U+25BC BLACK DOWN-POINTING TRIANGLEand it's decimal character entity is
▼
- ▲ 是U+25B2 BLACK UP-POINTING TRIANGLE它的十进制字符实体是
▲
- ▼ 是U+25BC BLACK DOWN-POINTING TRIANGLE它的十进制字符实体是
▼
I usually use the excellent Gucharmapto look up Unicode characters. It's installed on all recent Linux installations with Gnome under the name "Character Map". I don't know of any equivalent tools for Windows or Mac OS X, but its homepage lists a few.
我通常使用优秀的 Gucharmap来查找 Unicode 字符。它安装在所有最近的带有 Gnome 的 Linux 安装中,名称为“Character Map”。我不知道有任何适用于 Windows 或 Mac OS X 的等效工具,但它的主页列出了一些。
回答by John Slegers
There are several correct ways to display a down-pointing and upward-pointing triangle.
有几种正确的方法可以显示向下和向上的三角形。
Method 1 : use decimal HTML entity
方法 1:使用十进制 HTML 实体
HTML :
HTML :
▲
▼
Method 2 : use hexidecimal HTML entity
方法 2:使用十六进制 HTML 实体
HTML :
HTML :
▲
▼
Method 3 : use character directly
方法三:直接使用字符
HTML :
HTML :
▲
▼
Method 4 : use CSS
方法四:使用CSS
HTML :
HTML :
<span class='icon-up'></span>
<span class='icon-down'></span>
CSS :
CSS :
.icon-up:before {
content: "B2";
}
.icon-down:before {
content: "BC";
}
Each of these three methods should have the same output. For other symbols, the same three options exist. Some even have a fourth option, allowing you to use a string based reference (eg. ♥
to display ?).
这三种方法中的每一种都应该具有相同的输出。对于其他符号,存在相同的三个选项。有些甚至还有第四个选项,允许您使用基于字符串的引用(例如♥
显示?)。
You can use a reference website like Unicode-table.comto find which icons are supported in UNICODE and which codes they correspond with. For example, you find the values for the down-pointing triangle at http://unicode-table.com/en/25BC/.
您可以使用像Unicode-table.com这样的参考网站来查找 UNICODE 支持哪些图标以及它们对应的代码。例如,您可以在http://unicode-table.com/en/25BC/ 找到向下三角形的值。
Note that these methods are sufficient only for icons that are available by default in every browser. For symbols like ?,?,★,?,?,? or ?, this is far less likely to be the case. While it is possible to provide cross-browser support for other UNICODE symbols, the procedure is a bit more complicated.
请注意,这些方法仅适用于每个浏览器中默认可用的图标。对于像 ?,?,★,?,?,? 或者?,这种情况的可能性要小得多。虽然可以为其他 UNICODE 符号提供跨浏览器支持,但过程有点复杂。
If you want to know how to add support for less common UNICODE characters, see Create webfont with Unicode Supplementary Multilingual Plane symbolsfor more info on how to do this.
如果您想知道如何添加对不太常见的 UNICODE 字符的支持,请参阅使用 Unicode 补充多语言平面符号创建 webfont 以获取有关如何执行此操作的更多信息。
Background images
背景图片
A totally different strategy is the use of background-images instead of fonts. For optimal performance, it's best to embed the image in your CSS file by base-encoding it, as mentioned by eg. @weasel5i2 and @Obsidian. I would recommend the use of SVG rather than GIF, however, is that's better both for performance and for the sharpness of your symbols.
一个完全不同的策略是使用背景图像而不是字体。为了获得最佳性能,最好通过基本编码将图像嵌入到您的 CSS 文件中,如 eg. 所述。@weasel5i2 和 @Obsidian。我建议使用 SVG 而不是 GIF,但是,这对性能和符号的清晰度都更好。
This following code is the base64 for and SVG version of the icon :
以下代码是图标的 base64 和 SVG 版本:
/* size: 0.9kb */
url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTYiIGhlaWdodD0iMjgiIHZpZXdCb3g9IjAgMCAxNiAyOCI+PGcgaWQ9Imljb21vb24taWdub3JlIj48L2c+PHBhdGggZD0iTTE2IDE3cTAgMC40MDYtMC4yOTcgMC43MDNsLTcgN3EtMC4yOTcgMC4yOTctMC43MDMgMC4yOTd0LTAuNzAzLTAuMjk3bC03LTdxLTAuMjk3LTAuMjk3LTAuMjk3LTAuNzAzdDAuMjk3LTAuNzAzIDAuNzAzLTAuMjk3aDE0cTAuNDA2IDAgMC43MDMgMC4yOTd0MC4yOTcgMC43MDN6TTE2IDExcTAgMC40MDYtMC4yOTcgMC43MDN0LTAuNzAzIDAuMjk3aC0xNHEtMC40MDYgMC0wLjcwMy0wLjI5N3QtMC4yOTctMC43MDMgMC4yOTctMC43MDNsNy03cTAuMjk3LTAuMjk3IDAuNzAzLTAuMjk3dDAuNzAzIDAuMjk3bDcgN3EwLjI5NyAwLjI5NyAwLjI5NyAwLjcwM3oiIGZpbGw9IiMwMDAwMDAiPjwvcGF0aD48L3N2Zz4=
When to use background-images or fonts
何时使用背景图像或字体
For many use cases, SVG-based background images and icon fonts are largely equivalent with regards to performance and flexibility. To decide which to pick, consider the following differences:
对于许多用例,基于 SVG 的背景图像和图标字体在性能和灵活性方面基本相同。要决定选择哪个,请考虑以下差异:
SVG images
SVG 图像
- They can have multiple colors
- They can embed their own CSS and/or be styled by the HTML document
- They can be loaded as a seperate file, embedded in CSS AND embedded in HTML
- Each symbol is represented by XML code or base64 code. You cannot use the character directly within your code editor or use an HTML entity
- Multiple uses of the same symbol implies duplication of the symbol when XML code is embedded in the HTML. Duplication is not required when embedding the file in the CSS or loading it as a seperate file
- You can not use
color
,font-size
,line-height
,background-color
or other font related styling rules to change the display of your icon, but you can reference different components of the icon as shapes individually. - You need some knowledge of SVG and/or base64 encoding
- Limited or no support in old versions of IE
- 它们可以有多种颜色
- 他们可以嵌入自己的 CSS 和/或由 HTML 文档设置样式
- 它们可以作为单独的文件加载,嵌入在 CSS 中和嵌入在 HTML 中
- 每个符号都由 XML 代码或 base64 代码表示。您不能直接在代码编辑器中使用该字符或使用 HTML 实体
- 当 XML 代码嵌入 HTML 时,同一符号的多次使用意味着符号的重复。将文件嵌入 CSS 或将其作为单独文件加载时不需要重复
- 不能使用
color
,font-size
,line-height
,background-color
或其他字体相关的样式规则更改图标的显示,但可以参考的图标作为单独的形状不同的组件。 - 您需要了解 SVG 和/或 base64 编码
- 对旧版本 IE 的支持有限或不支持
Icon fonts
图标字体
- An icon can have but one fill color, one background color, etc.
- An icon can be embedded in CSS or HTML. In HTML, you can use the character directly or use an HTML entity to represent it.
- Some symbols can be displayed without the use of a webfont. Most symbols cannot.
- Multiple uses of the same symbol implies duplication of the symbol when your character embedded in the HTML. Duplication is not required when embedding the file in the CSS.
- You can use
color
,font-size
,line-height
,background-color
or other font related styling rules to change the display of your icon - You need no special technical knowledge
- Support in all major browsers, including old versions of IE
- 一个图标只能有一种填充颜色、一种背景颜色等。
- 图标可以嵌入在 CSS 或 HTML 中。在 HTML 中,可以直接使用字符,也可以使用 HTML 实体来表示。
- 有些符号可以在不使用 webfont 的情况下显示。大多数符号不能。
- 当您的字符嵌入 HTML 时,同一符号的多次使用意味着该符号的重复。在 CSS 中嵌入文件时不需要重复。
- 您可以使用
color
,font-size
,line-height
,background-color
或其他字体相关的样式规则更改图标的显示 - 您不需要特殊的技术知识
- 支持所有主流浏览器,包括旧版 IE
Personally, I would recommend the use of background-images only when you need multiple colors and those color can't be achieved by means of color
, background-color
and other color-related CSS rules for fonts.
就我个人而言,我建议仅当您需要多种颜色并且这些颜色无法通过color
,background-color
和其他与颜色相关的字体 CSS 规则来实现时才使用背景图像。
The main benefit of using SVG images is that you can give different components of a symbol their own styling. If you embed your SVG XML code in the HTML document, this is very similar to styling the HTML. This would, however, result in a web page that uses both HTML tags and SVG tags, which could significantly reduce the readability of a webpage. It also adds extra bloat if the symbol is repeated across multiple pages and you need to consider that old versions of IE have no or limited support for SVG.
使用 SVG 图像的主要好处是您可以为符号的不同组件赋予自己的样式。如果您将 SVG XML 代码嵌入到 HTML 文档中,这与设置 HTML 样式非常相似。但是,这会导致网页同时使用 HTML 标签和 SVG 标签,这会显着降低网页的可读性。如果该符号在多个页面中重复出现,并且您需要考虑旧版本的 IE 对 SVG 没有或有限的支持,它还会增加额外的膨胀。
回答by Williham Totland
You don't need to use character codes; just use UTF-8 and put them in literally; like so:
您不需要使用字符代码;只需使用 UTF-8 并将它们放在字面上;像这样:
▲▼
If you absolutely must use the entites, they are ▲ and ▼, respectively.
如果你绝对必须使用实体,它们是 ▲ 和 ▼,分别。
回答by paxdiablo
回答by Karel Frajták
Check this page http://www.alanwood.net/unicode/geometric_shapes.html, first is "9650 ▲ 25B2 BLACK UP-POINTING TRIANGLE (present in WGL4)" and 2nd "9660 ▼ 25BC BLACK DOWN-POINTING TRIANGLE (present in WGL4)".
检查此页面http://www.alanwood.net/unicode/geometric_shapes.html,第一个是“9650 ▲ 25B2 BLACK UP-POINTING TRIANGLE(出现在 WGL4 中)”和第二个“9660 ▼ 25BC BLACK DOWN-POINTING TRIANGLE(出现在WGL4)”。