css - SVG IMG 在 Firefox 中 float 时尺寸为零

标签 css firefox svg

<分区>

我对 Firefox 中 IMG 标签中使用的 SVG 有点困惑。

首先是 Codepens:

  1. http://codepen.io/doughamlin/pen/Fgosn
  2. http://codepen.io/doughamlin/pen/zmBda

Codepen 1 使用 SVG 并且不能在 Firefox(版本 26)中运行。 Codepen 2 使用 JPG 并在 Firefox 中正常工作。两者之间没有其他区别。它们都可以在 Chrome、Safari 和 IE 10 中正常工作。

Firefox 中的检查器显示 SVG 的高度和宽度为 0。如果我从包含 IMG 标签的 H1 中删除 float:left ,则 SVG 显示正常,但我没有找到其他方法来使 SVG 显示我无法弄清楚为什么图像首先具有 0 维.

这只是一些模糊的 Firefox 错误,还是我确实做错了什么?

最佳答案

这篇文章将帮助您了解为什么它不起作用

https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/SVG_Image_Tag

There are some important things to take note of (referenced from the W3 specs):

If you do not set the x or y attributes, they will be set to 0.

If you do not set the height or width attributes, they will be set to 0. Having a height or width attribute of 0 will disable rendering of the image.

关于css - SVG IMG 在 Firefox 中 float 时尺寸为零,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21738612/

相关文章:

html - 为什么 flex 元素不缩小过去的内容大小?

css - 如何使只有一行列表比屏幕宽?

当位置改变时,CSS 转换在 Firefox 中不起作用

firefox - 有没有办法在 Firefox 中运行 Dart 用于开发目的?

css - 不规则的 Div 形状仅扭曲一个 Angular

css - 将自定义页眉和页脚添加到 wordpress 博客

Canvas 的 JavaScript 问题 - Chrome 中正常/Firefox 中错误

c# - 无法使用 C# 和摘要式身份验证连接到 TLS Web 服务,Firefox 在 IE8 失败的地方成功

css - SVG 动画飞机环绕地球

javascript - jQuery 单击功能可从元素中删除属性并在单独单击时恢复属性