css - SVG 字母间距也适用于 Mozilla Firefox

标签 css google-chrome firefox text svg

SVG 文本而言,是否有替代字母间距的方法?

此代码适用于 Chrome不适用于 Firefox:

https://developer.mozilla.org/de/docs/Web/CSS/letter-spacing

如您所见,由于 bug,Firefox 现在不支持它。但我真的需要在两个浏览器中使用字母间距。那么 SVG 文本有好的替代方案吗?

顺便说一句,字间距也是如此。在 Chrome 中完美运行,但在 Firefox 中运行不佳。

最佳答案

letter-spacing 的替代方案在 Firefox 上有效,是 textLength 属性。也许这适合您作为解决方法?

<svg width="10cm" height="3cm" viewBox="0 0 1000 300"
     xmlns="http://www.w3.org/2000/svg" version="1.1">
  <desc>Example text01 - 'Hello, out there' in blue</desc>

  <text x="250" y="150" 
        font-family="Verdana" font-size="55" fill="blue" >
    Hello, out there
  </text>

  <text x="250" y="200" textLength="600"
        font-family="Verdana" font-size="55" fill="blue" >
    Hello, out there
  </text>

  <!-- Show outline of canvas using 'rect' element -->
  <rect x="1" y="1" width="998" height="298"
        fill="none" stroke="blue" stroke-width="2" />
</svg>

关于css - SVG 字母间距也适用于 Mozilla Firefox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28644626/

相关文章:

html - chrome 单选按钮上的白色背景

javascript - 从一个简单的网站访问 Firefox 插件的功能

html - 截断时使绝对定位元素滚动

javascript - 为什么我的 for 循环从最后一项开始并在一次迭代后停止运行?

css - Flexbox 没有在 div 之间应用空间

javascript - Canvas 已通过本地 chrome ://extension URL 被跨源数据污染

javascript - 仅在 IndexedDB 中更新对象后运行代码(特别是在 Chrome 中)

HTML+CSS 工具提示 : Weird behavior in table with rowspan

firefox - 安装 Firefox Addon SDK Python 时出错

css : In chrome , 为什么表格宽度超出其容器宽度?