【问题标题】:Bootstrap Header Logo Image Not Showing in MozillaBootstrap 标头徽标图像未在 Mozilla 中显示
【发布时间】:2015-07-14 17:24:04
【问题描述】:

请记住,我对 HTML 和 CSS 相当陌生。我网站上的引导标头中有一个徽标 (www.prettyugly.co.nz)

我最初使用下面的代码来显示它,它在 Chrome 中运行良好

.image {
  content: url("/img/logo-white.png");
}

然后这个在 HTML 中调用那个 CSS

<div class="image"></div>

我后来了解到您必须使用 :before 命令才能让内容在 Firefox 中运行,但我无法让它全面运行。

有什么想法吗?

【问题讨论】:

  • content 替换为backgroundbackground-image
  • 您是否还必须为此指定一个尺寸,还是仅以图像尺寸的 100% 显示?
  • 你有很多可能性,了解更多herehere
  • 感谢您的评论,但它仍然没有显示图像。 background: url("/img/logo-white.png");background-image: url("/img/logo-white.png"); 都不起作用。

标签: javascript html css twitter-bootstrap firefox


【解决方案1】:

您应该简单地使用 (HTML) 显示图像:

<div><img src="/img/logo-white.png" /></div>

但是如果你想设置为background,那么你应该使用(CSS):

.image {
    background-image: url("/img/logo-white.png");
    width: 225px; height: 63px; /* Dimensions of image */
}

【讨论】:

  • 感谢您的回复。我刚刚尝试过,它显示在 Chrome 上,但不是 Firefox。请参阅此链接以获取屏幕截图 - iforce.co.nz/i/c2utjpbe.hju.jpg
  • 我使用的是 Firefox,我可以看到图像。您还需要设置width: 225px; height: 63px;
  • 哦,它现在可以工作了!谢谢 :) 有没有办法可以在 CSS 中添加 alt 标签以进行 SEO?
  • 没有必要,只有当你在 HTML 中使用img 标签时:) 你可以read this article 来讨论。
猜你喜欢
  • 1970-01-01
  • 2019-04-03
  • 1970-01-01
  • 2011-03-31
  • 2021-07-14
  • 1970-01-01
  • 2014-11-30
  • 1970-01-01
  • 2021-10-11
相关资源
最近更新 更多