2014-05-09 95 views
0

我需要为我的网站将不会使用的区域设置背景图像。如何设置背景?

http://oi61.tinypic.com/903z4l.jpg

我需要在网站的灰色部分添加背景图片。

我的HTML代码:

<html> 
<body> 
<?php include 'banner.php'; ?> 
</body> 
</html> 

横幅和导航代码,我已经将其设置为中心和banner.php 800像素,为u在PIC看到:

#nav 
{ 
margin-left:auto; 
margin-right:auto; 
width:800px; 
} 
+0

创建一个div,这是你想要背景的位置,而不是像CSS那样使用'background:url('something.png');' –

+0

background:url(path/to/image.jpg); –

+0

@安迪没有工作。 – user3545779

回答

1

添加background到HTML的body。这可以用CSS来完成。

CSS:

body { 
    background-image:url("background.jpg"); 
} 

注:此背景会重复一遍又一遍,以使其绝后你可以使用:

body { 
    background:url("background.jpg") no-repeat; 
} 

更新:

你的HTML代码,需要有与navid一个div,所以它重叠在背景:

<html> 
<body> 
    <div id="nav"></div> 
</body> 
</html> 

所有你添加到DIV导航内容现在重叠的背景。

+0

它完全设置背景。我不想在800像素以内。 – user3545779

+0

为您的php内容添加白色背景。 –

+0

它完全设置背景,但内容与背景重叠,所以您应该在其上添加一个800像素的div。 –

0
body{ 
    background:url('image.png'); 
} 
.centerDiv{ 
    width:800px; 
    margin:0 auto; 
    background:#fff; 
    height:100%; 
} 

这应该适合你。