Netbeans中的HTML图像未显示在浏览器中

时间:2017-06-17 16:10:30

标签: html css image netbeans



*{
    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>
&#13;
&#13;
&#13;

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

5 个答案:

答案 0 :(得分:0)

确保你有正确的道路(例如:relative ./your_file.png

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

答案 1 :(得分:0)

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

答案 2 :(得分:0)

以下代码行表示您的图片文件img.png位于保存html文件的同一文件夹中。

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

如果它保存在其他文件夹中,则可以提供类似

的相关路径
src="../foldername/img.png"

答案 3 :(得分:0)

我试图从%temp%命令中清除临时文件,但它确实有效!

答案 4 :(得分:0)

如果您的HTML文件和图片有两个不同的文件夹,请按以下步骤更新您的img标记:

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

,其中&#34;图像&#34;是放置图像的文件夹的名称。