2012年3月7日星期三

用DIV布局制作公告板

一、图片素材:

1、公告板顶部(top.gif)

2、公告板中部(center.gif)

3、公告板底部(bottom.gif)

三张图片的宽度是一样的。

二、DIV布局制作公告板:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html ="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用DIV/CSS制作公告板</title>
<style type="text/css">
* {
margin:0;
padding:0;
border:0;
}
#box {
width:406px;
height:227px;
}
#top {
float:left;
height:68px;
width:100%;
background-image:url(top.gif);
}
#center {
float:left;
height:109px;
width:100%;
background-image:url(center.gif);
background-repeat:repeat-y;
}
#bottom {
float:left;
height:51px;
width:100%;
background-image:url(bottom.gif);
}
</style>
</head>

<body>
<!--DIV块box包含top,center,bottom块-->
<div id="box">
<div id="top"></div>
<div id="center"><!--在此可添加公告板的内容--></div>
<div id="bottom"></div>
</div>
</body>
</html>

注意:DIV块box高度为其之内的三个DIV块高度之和,box块中的三个块的宽度设定为100%,代表和box块的宽度一致,这样使布局显得紧凑

三、公告板效果:

公告板内容可以添加在DIV块center中。




用DIV布局制作公告板

TAG:Html/CSS