【问题标题】:html gif has transparent background but gets white in img tag and css background attributeHTML GIF具有透明的背景,但在IMG标签和CSS背景属性中获取白色
【发布时间】:2019-11-18 23:52:28
【问题描述】:

我有一个透明背景的 gif 图像,您可以在我的桌面上看到:

但是当我在我的 html 代码中使用它时,会得到白色背景。 我已经在 stackoverflow 和谷歌首页的其他网站中测试了背景 css 属性和回复。 这是我的代码:

<img src="/content/elecomp98/pahbad.gif" style="position: absolute;top: 50px;left: 0;width: 250px;">

<div style="width: 250px;height: 280px;background: url(/content/elecomp98/pahbad.gif);position: absolute;left: 0;top: 50px;background-size: cover;display: none;"></div>

【问题讨论】:

  • 寻求代码帮助的问题必须包含重现它所需的最短代码在问题本身中最好在Stack Snippet 中。见How to create a Minimal, Reproducible Example。 我们需要 ACTUAL 图片。
  • 当然。但它的问题很简单,没有其他详细信息。
  • 我添加了另一张更清晰地显示问题的图片。
  • 另请注意,“Pahbad.gif”与“pahbad.gif”不同。
  • @Paulie_D 你救了我的命。添加此答案,以便我确认。

标签: html css gif


【解决方案1】:

请注意,“Pahbad.gif”与“pahbad.gif”不同。

图片网址区分大小写。

级联样式表 (CSS) 不区分大小写。但是,字体系列、图像的 URL 以及样式表的其他直接引用可能是。

我建议您链接错误的图像。

【讨论】:

    猜你喜欢
    • 2021-03-26
    • 2012-07-26
    • 1970-01-01
    • 1970-01-01
    • 2014-08-21
    • 2011-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多