【问题标题】:Image not shown properly in firefox图像在 Firefox 中未正确显示
【发布时间】:2014-07-25 02:13:44
【问题描述】:

如果图像在文件夹中不可用,则浏览器仅显示具有给定高度和宽度的 img 标签,但 Firefox 在这种情况下会产生问题..

问题:我正在使用 img 属性来显示图像。在Firefox中它看起来像 我正在使用 style="width: 180px; height: 185px;"

但在 chrome 中看起来像

【问题讨论】:

  • 你能在这里添加你的代码或摆弄它吗?
  • 在此处发布您的代码或与我们分享链接....

标签: html css image google-chrome firefox


【解决方案1】:

试试这个:

@-moz-document url-prefix(http), url-prefix(file) {
    img:-moz-broken{
    -moz-force-broken-image-icon:1;
    width:180px;
    height:185px;
    border:1px solid #000;
    }
}

Example jsfiddle.

编辑:Gaurav 发布的解决方案更好,请改用它。

-moz-force-broken-image-icon

不建议使用此属性。应该使用适当的 alt 属性。

【讨论】:

  • 它在 mozilla 中运行良好,但在 chrome 中不行。你能提供两者的代码吗
  • 您要删除 Chrome 中的图片占位符吗?
【解决方案2】:

删除属性alt="" 它也可以在 Mozilla 中使用。

Demo

HTML

<img src="youImage.jpg" style="width: 180px; height: 185px;"/>

Mozilla


如果你也想拥有 alt **Demo **

【讨论】:

  • 感谢您的回答,但我已经没有在 img 中使用 alt
猜你喜欢
  • 2016-01-15
  • 1970-01-01
  • 2021-05-06
  • 1970-01-01
  • 1970-01-01
  • 2015-04-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多