HTML 中数字的重音符号(如 1 上的 ^)

发布于 2024-08-11 09:18:37 字数 1361 浏览 3 评论 0 原文

我正在尝试找到将扬抑符 ( ˆ = ˆ) 放在数字(乐谱)之上而不求助于图像的最佳方法。某些字母具有等效的 HTML 实体:ê = ê、Ô = Ô 等,但数字则不然。

这是我目前在我的网站上使用的内容:

<span style="position:relative;">1
   <span style="position:absolute; 
                left:0.1em; 
                bottom:0.2em; 
                font-size:1.1em;">
                &circ; 
   </span>  
</span>

它看起来不错,但并不完美——由于数字形状和浏览器渲染的细微差别,某些内容肯定会有些偏差。

有人对此有更优雅的解决方案吗?

更新:

组合抑扬符 &#770;&#x302; 在不同的浏览器/平台上产生不同的结果,其中大多数不正确(在我的 Mac 上,只有 Safari 正确)。

根据 this,组合重音的正确显示取决于字体和渲染器。我正在使用 Times New Roman, Times,因此它似乎不是一个可行的选项。我无法承受要求用户使用特定字体的麻烦和不可避免的忽视。

我想我必须坚持像上面那样手动将重音放置在注释上方,除非有任何其他新答案。谢谢。

更新2:

嵌入具有更好变音符号支持的免费字体(尤其是Doulos SIL)看起来很有前途,但截至目前(2009 年 11 月),Chrome 默认不支持 CSS 中的 @font-face。不过,一旦实现,那就太好了,因为其他浏览器已经加入了。 webfonts.info 是提供这方面信息的地方。

I'm trying to find the best way to put circumflex accents ( ˆ = ˆ) on top of numbers (a musical notation) without resorting to images. Certain letters have equivalent HTML entities: ê = ê, Ô = Ô, etc., but numbers don't.

Here is what I'm currently using on my website:

<span style="position:relative;">1
   <span style="position:absolute; 
                left:0.1em; 
                bottom:0.2em; 
                font-size:1.1em;">
                ˆ 
   </span>  
</span>

It looks pretty good, but not perfect---because of slight differences in number shapes and browser rendering, something is bound to be a little off.

Does anyone have a more elegant solution for this?

Update:

The Combining Circumflex Accent ̂ or ̂ produces different results on different browsers/platforms, most of which are not right (on my Mac, only Safari does it right).

According to this, proper display of a combining accent is dependent on both the font and the renderer. I'm using Times New Roman, Times, so it doesn't appear to be a workable option. I can't afford the hassle and inevitable ignoring of requiring a user to have a particular font.

I guess I'll have to stick with manually positioning the accent atop the note as above unless there's any other new answers. Thanks.

Update 2:

Embedding a free font with better diacritic support (especially Doulos SIL) seemed promising, but as of now (Nov 2009), Chrome does not support @font-face in CSS by default. Once it does, though, it will be great, since the other browsers are already on board. webfonts.info is the place for info on this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

热风软妹 2024-08-18 09:18:37

U+0302 组合圆周重音

用字符图或实体制作一个

 ̂

将其放在您想要的任何内容之后,将其粘贴在其上:

ê Â 1̂ :)̂

变为

ê 1̂ :)̂

...但它的设计目的不是为了覆盖 1 或笑脸。请注意 A 的位置向上移动,但 1 或笑脸的位置没有移动。

U+0302 COMBINING CIRCUMFLEX ACCENT

Make one with character map or with the entity

 ̂

Stick one over anything you want by putting it after it:

ê Â 1̂ :)̂

Becomes

ê Â 1̂ :)̂

...but it's not designed to go over the 1 or the smiley face. Notice how it moved up higher for the A but not for the 1 or the smiley face.

三五鸿雁 2024-08-18 09:18:37

尝试使用 ̂̂组合循环重音 (U+0302):

示例:

Try the COMBINING CIRCUMFLEX ACCENT (U+0302) using ̂ or ̂:

Example:

下雨或天晴 2024-08-18 09:18:37

很大程度上取决于您的用户使用的字体是否支持此功能。由于您无法在网页中嵌入字体(没有一些潜在的法律问题),因此您最好的选择是使用不同的字体尝试上述建议,以确定您要查找的字符是否受支持。找到字体后,在 CSS 文件中引用它,然后通知用户需要特定字体才能正确查看您的网站。

尝试使用以下 unicode 索引: http://www.fileformat.info/info /unicode/char/a.htm

您需要知道要显示的字符的名称。找到该字符后,信息页面将告诉您如何使用 HTML 字符代码显示该字符。

A lot will depend on whether or not the font your user is using supports this feature. Since you cannot embed fonts in a web page (without some potential legal trouble), your best bet is to try the above suggestions with different fonts to determine if the character your looking for is supported. Once you find a font, reference it in your CSS file and then inform the user that a specific font is required to correctly view your site.

Try using the following unicode index: http://www.fileformat.info/info/unicode/char/a.htm

You will need to know the name of the character you are trying to display. Once you've found it, the information page will tell you how to display the character using HTML character codes.

陌路黄昏 2024-08-18 09:18:37

查看组合变音标记常见问题解答。组合抑扬符是 U+0302。

该部分说:“某些字体,例如 Doulos 和 Charis 字体,可以免费下载,包含大量适当的预组合字形”。让您的用户下载这些字体可能值得尝试(如果它们有效)。

您可能会成功缩小数量:

<span style="font-size: 75%">1</span>̂

Check out the combining diacritical marks faq. A combining circumflex is U+0302.

That section says: "Some fonts, such as the Doulos and Charis fonts, which are freely available for download, contain large repertoires of appropriate precomposed glyphs". It might be worth a try to get your users to download those fonts (if they work).

You might have some success shrinking the number:

<span style="font-size: 75%">1</span>̂
蘸点软妹酱 2024-08-18 09:18:37

如果组合标记的渲染不够好,我想您将不得不通过定位来解决它。

<style>
    .over { position: relative; }
    .over span { position: absolute; top: -0.5em; left: 0; }
</style>

abc <span class="over">1<span>^</span></span> xyz

仍然是一个令人讨厌的黑客!但工作量可能比 MathML 少。

If rendering of the combining mark isn't sufficiently good I guess you would have to hack it up with positioning.

<style>
    .over { position: relative; }
    .over span { position: absolute; top: -0.5em; left: 0; }
</style>

abc <span class="over">1<span>^</span></span> xyz

Still a nasty hack! But possibly less work than MathML.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文