【问题标题】:HTML in Netbeans image not showing in browserNetbeans 图像中的 HTML 未在浏览器中显示
【发布时间】:2022-01-23 19:38:54
【问题描述】:

*{
    margin: 0px;
    padding: 0px;
}
.container{
    background-color:#999999;
    width:100%;
    margin-top: 10px;
}
.wrapper{
    margin-top: 50px;
    width:900px;
    margin:auto;
}
.dark{
    background-color: #FF4500;
    height: 40px;
    margin-top: 40px;
}
#top_div{
    line-height: 40px;
}
#div2{
    height: 220px;
}

上面提到的是我的css文件

 <html xmlns="https://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>My static web Page</title>
        <link type="text/css" rel="stylesheet" href="css1.css"/>
    </head> 
    <body>
        
        <div class="container">
            <div class="wrapper">
                <div>
                    <img src="img.png"  width="400" height="400" ></img>
                </div>
            </div>
        </div>
        
        <div class="dark">
            <div class="wrapper" id="top_div">
                <h2>The Origin</h2>
            </div>
        </div>
        
        <div class="container">
            <div class="wrapper" id="top_div">
This is my styled paragraph
            </div>
        </div> 
        
    </body>
</html>

它只显示图像图标,在浏览器上看不到图像。 我已将图像粘贴到项目目录内的文件夹中。添加图片的正确方法是什么,请解释一下。

【问题讨论】:

    标签: html css image netbeans


    【解决方案1】:

    确保你有正确的路径(例如:相对的./your_file.png

    <div>
         <img src="./img.png"  width="400" height="400" ></img>>
    </div>
    

    【讨论】:

      【解决方案2】:
      <div>
      <img src="./foldername/imagename.png" width="400" height="400" />
      </div>
      

      【讨论】:

        【解决方案3】:

        以下代码行意味着,您的图像文件img.png 位于您保存html 文件的同一文件夹中。

        <img src="img.png"  width="400" height="400" ></img>
        

        如果它保存在其他文件夹中,您可以提供相关路径,例如

        src="../foldername/img.png"
        

        【讨论】:

          【解决方案4】:

          我试图从 %temp% 命令中清除临时文件,它成功了!

          【讨论】:

            【解决方案5】:

            如果您的 HTML 文件和图像有两个不同的文件夹,请更新您的 img 标签,如下所示:

            &lt;img src="../images/img.png" width="400" height="400" &gt;&lt;/img&gt;

            其中“images”是放置图片的文件夹的名称。

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2015-04-16
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2022-07-13
              • 2021-06-13
              • 1970-01-01
              • 2017-08-11
              相关资源
              最近更新 更多