Firefox CSS图像框

Firefox CSS图像框,css,firefox,Css,Firefox,除了FireFox之外,此CSS代码在所有浏览器中都有效。为什么?我怎样才能修好它 .img_box { width: 110px; height: 160px; background-repeat: no-repeat; background-position: center center; background-image: url('https://www.google.com/images/srpr/logo3w.png'); } 提前谢谢 编辑: 以下是我要使用的

除了FireFox之外,此CSS代码在所有浏览器中都有效。为什么?我怎样才能修好它

.img_box {
  width: 110px;
  height: 160px;
  background-repeat: no-repeat;
  background-position: center center;
  background-image: url('https://www.google.com/images/srpr/logo3w.png');
}
提前谢谢

编辑: 以下是我要使用的HTML:

<img class="img_box" />

当Firefox遇到一个没有来源的图像时,它会用alt文本替换该图像。我个人觉得这非常烦人,因为这意味着除非我专门创建占位符图像,否则我无法测试布局,如果这些图像因任何原因不可用,布局将完全中断

不幸的是,我还没有找到解决这个问题的办法


但是,在您的情况下,最好使用
div
并将
display:inline block
添加到CSS中,而不是使用图像。

解决方案1:

.img_box {
  width: 110px;
  height: 160px;
  background-repeat: no-repeat;
  background-position: center center;
  background-image: url('https://www.google.com/images/srpr/logo3w.png');
  display: block;
}
<div class="img_box"></div>
解决方案2:

.img_box {
  width: 110px;
  height: 160px;
  background-repeat: no-repeat;
  background-position: center center;
  background-image: url('https://www.google.com/images/srpr/logo3w.png');
  display: block;
}
<div class="img_box"></div>


起作用/不起作用的二分法并非相互详尽。所以,我会回答“是的”。什么不起作用?高度?宽度?背景图像?具体的人!Firefox这样做的原因是,用户可以实际读取alt文本(其他浏览器使之非常困难)。这就是Firefox的目标;使用没有src的图像进行测试是一种边缘情况。当然,如果一个布局中断,如果一个图像不可用,它也会中断,如果用户关闭了图像,所以它只是一开始就有点中断。也就是说,您可以使用
-moz force breaked image icon:1
设置“刚刚测试”图像的样式,以强制使用大小的框渲染图像,即使没有实际的图像显示。呃。。。那么,当浏览器在图标旁边显示带有alt文本的损坏图像时,是否不可读?我猜不是在小图片上,但仍然…准确地说。对于绝大多数中小型图像,如果书写正确,alt文本太长,在大多数UAs显示的小型框中实际上无法读取。。。。