html - alt 和标题未显示为 svg 路径的工具提示

标签 html svg

我有一些 svg 路径:

<path class="country" id="BLR" title="Belarus" alt="Belarus" d="M948.0142678672362,369.7256153651123L956.0315144997886,372.7549948212553L955.6251153181965,376.68106491420883L956.6993702966163,377.46634055469417L958.4144244330968,381.52092337306806L959.8614899624631,381.6111705103533L961.4358247718692,383.8516898475525L959.6328069741484,385.0654037682009L957.3752698953709,384.53552051711677L958.4665656000917,390.0076939606045L955.9148066459876,390.24630230981074L954.0730841220384,394.2297858860991L953.163550030379,393.0762648682822L950.333965883297,393.353478804788L943.9500919704785,392.13801133565164L939.2092506948762,390.2052953894462L934.5569856401167,390.2170281135237L931.9231336584982,391.7484512915885L932.3814647774813,388.98495674038986L931.0289993180527,387.81385807072303L933.4265401596901,386.10558265025156L933.7995387046943,384.91739193713676L933.1171566924312,379.6478010722885L935.6115604269471,380.1186619031289L939.5640872868389,378.3386011842294L940.8357423463007,375.41130363641486L942.8397126276869,373.56246283729985L943.307715755223,371.87935555833474L946.3215777553021,371.35369709054953Z"></path>

我有每条路径的 title 和 alt。当我将鼠标悬停在 Firefox 中的路径上时,我会看到带有国家名称的小工具提示。但是当我在 IE 或 Chrome 中这样做时,没有任何反应。请问有人知道为什么吗?

最佳答案

显然,在 Chrome 中执行此操作的正确方法是添加 <title>元素作为子元素。参见 here有关此问题的更多详细信息。

所以它应该是这样的:

<path>
    <title>Belarus</title>
</path>

这是一个live example

关于html - alt 和标题未显示为 svg 路径的工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22867178/

相关文章:

jquery - 如何选择在mvc中动态选择的css类

html - 防止 float 元素返回下一行

javascript - 滚动时显示 div 并更改行为

html - 为什么 favicon 不能在 firefox 中加载?

javascript - D3.js:组合缩放/画笔

css - 使用 CSS 更改 SVG 高度

svg - 使用 Batik 绘制 SVG 选择框

php - 难以从两页注册中传递变量

css - css中的内联svg过滤器

d3.js - d3 - 触发鼠标悬停事件