【问题标题】:Images not being displayed [closed]图像未显示[关闭]
【发布时间】:2013-06-09 05:32:05
【问题描述】:
<html>
    <head>
    <link href="styles/main.css" type="text/css"
    rel="stylesheet" media="screen"/>


    </head>
    <body>
    <div id="wrapper">
    <?php include_once("forall.php");?>
    <?php include_once("template_nav.php"); ?>

    <div id="content"></div>


    <div id="footer">abcd</div>
    </div>
    </body>
    </html>

我的css代码:

*
{
margin:0px;
padding:0px;
}



 body
    {
        font-family: verdana;
        background-image: url(http://local host/Website/imagess/sp.jpg);

    }


#wrapper
{
    width: 1024px;
    margin-left: 120px;
    background-color: #ebebeb;
}
#header
{
height:200px;

}

.logo
{
    margin-top: 50px;
    float: left;

height::200px;
    background-image: url(http://local host/Website/imagess/sur99.jpg);


}

#searchbox
{
float:right;
margin-top:100px;

}

#nav{

    clear: both;
height:50px;
    margin-left: 30px;
        background-image: url(http://local host/Website/imagess/s4.jpg);
}
ul#navmenu,ul.submenu1
{
list-style-type:none;
}
ul#navmenu li
{
width:123px;
text-align:center;
position:relative;
float:left;
margin-right:4px;
padding:5px;

}

ul#navmenu a{
text-decoration:none;
display:block;
width:123px;
height:30px;
line-height:30px;

border-radius:5px;
color:white;
font-weight:bold;
margin-top:10px;

}

ul#navmenu .submenu1 a
{
margin-top:3px;
}

ul#navmenu li a:hover
{
background-color:black;
}

ul#navmenu ul.submenu1
{
display:none;
position:absolute;

}

ul#navmenu li:hover .submenu1
{
display:block;
}

.darrow
{
font-size:11pt; 
position:absolute;

top:21px;
right:16px;
color:white;
}


#footer
{
width:1024;
background-color:#696969;

}

包含文件“forall.php:

<div id="header">
<div class="logo">

</div>
<div id="searchbox">
<form id="searching">
<input type="text" name="forsearch">
<input type="button" name="search" 

value="search">
</form>
</div>
</div>

我已将根目录从 localhost/ 更改为“localhost/Website”,因为我的索引文件和图像(在 imagess 文件夹中)位于 wamp/www/Website 的网站文件夹中 当我在 WAMP 中运行我的页面时,不显示图像。 替代文字可见,但图像不可见。 请帮忙

【问题讨论】:

  • 这个 => http://local host 错误,另外你确定你的图片确实在imagess而不是images?键盘有时很拧。最好确保你的 Kool-Aid 没有溅到那里;-)
  • 我的猜测是基于他在代码下方的评论,即带有两个“s”的“imagess”是正确的。或者,他洒了几罐 Kool-Aid。 :)
  • @Ryaminal 曾经对我来说是咖啡,但我很快就解决了这个问题。我喝了我的键盘!现在我可以用任何语言说话和拼写,同时保持清醒。 ;-)
  • 就像 :::ELVIS::: - OP 已经离开了大楼。

标签: html css image


【解决方案1】:

在您的 CSS 更改中

background-image: url(http://local host/Website/imagess/sp.jpg);

到

background-image: url(http://localhost/Website/imagess/sp.jpg);

同样适用于所有背景图片。你在 url 的 localhost 中有一个空格。

【讨论】:

  • 为什么要这样做而不是background-image:url(../images/image-name.jpg); 没有理由包含绝对 URL,尤其是因为它是本地主机!没有任何意义。
  • 致所有合作的个人。我的文件夹名称是正确的,它的“imagess”请不要寻找拼写错误。我在发布问题之前已经完成了。当我在我的 index.php 页面中使用“”标签时,“alt”文本是可见的。包含图像的 div 是可见的。但是有损坏的图像图标。替代文本是可见的。但图像没有显示.
  • 当我使用我在代码中显示的内容通过 css 插入图像时。我想使用我的 css 页面将图像插入到我的索引页面中。但我做不到。我的图像没有显示。而其余的 CSS 属性正在得到完美应用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-02-08
  • 1970-01-01
  • 2014-10-16
  • 2020-11-23
  • 1970-01-01
  • 2012-06-10
  • 1970-01-01
相关资源
最近更新 更多