我需要为我的网站不会使用的区域设置背景图片。
http://oi61.tinypic.com/903z4l.jpg
我需要在网站的灰色部分添加背景图片。
我的HTML代码:
<html>
<body>
<?php include 'banner.php'; ?>
</body>
</html>
横幅和导航代码,我已将它们设置为banner.php的中心和800px,正如您在图片中看到的那样:
#nav
{
margin-left:auto;
margin-right:auto;
width:800px;
}
答案 0 :(得分:1)
将background
添加到HTML的body
。这可以通过CSS完成。
<强> CSS:强>
body {
background-image:url("background.jpg");
}
注意:此背景会反复重复,为了使不可重复您可以使用:
body {
background:url("background.jpg") no-repeat;
}
<强>更新强>
您的HTML代码需要div
id
nav
,因此它与背景重叠:
<html>
<body>
<div id="nav"></div>
</body>
</html>
您添加到div导航栏中的所有内容现在都会与背景重叠。
答案 1 :(得分:0)
body{
background:url('image.png');
}
.centerDiv{
width:800px;
margin:0 auto;
background:#fff;
height:100%;
}
这对你有用。