【问题标题】:Cannot add .png with transparent background or any picture to an HTML page无法将具有透明背景的 .png 或任何图片添加到 HTML 页面
【发布时间】:2021-11-10 00:06:33
【问题描述】:

我创建了一个这样的 HTML 页面:

<!DOCTYPE html>
<html>
    <head>
        <title>Title</title>
        <style>
            body {
                background-color: bisque;
            }
        </style>
    </head>
    <body>
        <img src="/cat.png">
    </body>
</html>

而cat.png图片是这样的:

它有一个透明的背景。但是我的页面是这样的:

那么,问题来了:为什么页面上没有显示图片?

【问题讨论】:

    标签: html png transparency


    【解决方案1】:

    原来我需要像这样在图片的路径中添加一个点:

    <img src="./cat.png">
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-29
      • 2014-08-07
      • 2012-12-19
      • 2020-12-09
      • 1970-01-01
      • 2013-07-17
      相关资源
      最近更新 更多