身体背景颜色和图像没有显示

时间:2013-10-28 13:52:20

标签: html css image colors background

因此.... 我有一个名为intro的文件夹。 在这个文件夹中都有index.html和style.css文件。在介绍文件夹中是另一个名为“images”的文件夹,我将存储我将使用的图像。在该文件夹(图像)中是一个名为background.jpg的图像

代码如下: HTML

    <!DOCTYPE html>
<html>
<head>
    <link type="text/css" rel="stylesheet" href="style.css"/>
    <title>test</title>
</head>
<body>

    <div id="content">
        <div class="info">
            Want to know more about Dreams?
        </div>

    </div>
</body>

CSS

    /*CSS Style Sheet*/
@font-face

body {
background-color: #080808;
background-image: url(images/background.jpg);
margin: auto;
}


#content {
width: 1000px;
background-color: #080808;
margin-left: auto;
margin-right: auto;
margin-top: 500px;
}

由于某种原因,背景图像和背景颜色没有显示出来。 bg颜色保持白色,图像无处可见。帮助

2 个答案:

答案 0 :(得分:0)

您必须从HTML文件的位置映射背景图像。例如,如果图像位于您的介绍文件夹中,并且您的HTML文件位于介绍中的单独文件夹中,那么它将是..\image\background.jpg。此外,您不需要CSS中的@font-face

在映射时,要返回文件夹,您可以使用..来暗示路径中的上一个文件夹。

答案 1 :(得分:0)

您在背景图片的路径上缺少“__”。

两个更改顺序并使用背景而不是背景图像。

 body {        
   background:url("images/background.jpg") no-repeat center;
   background-color:blue;
 }

三个.png文件可让您在图像中保持透明背景。

四删除@ font-face

查看此演示http://jsfiddle.net/e85kY/