简单的div+css布局之一
简单的div+css的实例布局,利用图片进行布局,首先要准备5张图片。
left-top.gif
right-top.gif
right.gif
left-bottom.gif

right-bottom.gif
p1

实例1代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>固定宽度 相对定位</title>
<style type="text/css">
body{
background:#fff;
font:13px/1.5 Arial, Helvetica, sans-serif;
margin:0;
padding:0;
}
.rounded{
background:#aaa url(images/lt.gif) top left no-repeat;
width:100%;
}
.rounded h2{
background:url(images/rt.gif) top right no-repeat;
padding:20px 20px 10px;
margin:0;
}
.rounded .main{
background:url(images/r.gif) top right repeat-y;
padding:10px 20px;
margin:-2em 0 0 0;
}
.rounded .footer{
background:url(images/lb.gif) bottom left no-repeat;
}
.rounded .footer p{
color:#888;
text-align:right;
background:url(images/rb.gif) bottom right no-repeat;
display:block;
padding:10px 20px 30px;
margin:-2em 0 0 0;
}
#header,#pagefooter,#containter{
width:760px;
margin: 0 auto;
}
#content{
width:497px;
float:left;
position:relative;
top:20px;
}
#content1{
width:260px;
}
#side{
width:497px;
float:left;
}
#side2{
width:260px;
}
</style>
</head>
<body>
<div id="header">
<div class="rounded">
<h2>Page Header</h2>
<div class="main">
<p>
这是一行文本,这里作为样例,显示在布局框中<br />
这是一行文本,这里作为样例,显示在布局框中
</p>
</div>
<div class="footer">
<p>
查看详细信息
</p>
</div>
</div>
</div>
<div id="containter">
<div id="content">
<div class="rounded">
<h2>Page Content</h2>
<div class="main">
<p>
这是一行文本,这里作为样例,显示在布局框中<br />
这是一行文本,这里作为样例,显示在布局框中
</p>
</div>
<div class="footer">
<p>
查看详细信息
</p>
</div>
</div>
</div>
<div id="content1">
<div class="rounded">
<h2>Page Content1</h2>
<div class="main">
<p>
这是一行文本,这里作为样例,显示在布局框中<br />
这是一行文本,这里作为样例,显示在布局框中
</p>
</div>
<div class="footer">
<p>
查看详细信息
</p>
</div>
</div>
</div></div>
<div id="containter">
<div id="side">
<div class="rounded">
<h2>Page Side</h2>
<div class="main">
<p>
这是一行文本,这里作为样例,显示在布局框中<br />
这是一行文本,这里作为样例,显示在布局框中
</p>
</div>
<div class="footer">
<p>
查看详细信息
</p>
</div>
</div></div>
<div id="side2">
<div class="rounded">
<h2>Page Side</h2>
<div class="main">
<p>
这是一行文本,这里作为样例,显示在布局框中<br />
这是一行文本,这里作为样例,显示在布局框中
</p>
</div>
<div class="footer">
<p>
查看详细信息
</p>
</div>
</div>
</div></div>
</div>
<div id="pagefooter">
<div class="rounded">
<h2>Page Footer</h2>
<div class="main">
<p>
这是一行文本,这里作为样例,显示在布局框中<br />
这是一行文本,这里作为样例,显示在布局框中
</p>
</div>
<div class="footer">
<p>
查看详细信息
</p>
</div>
</div>
</div>
</body>
</html>
p2

实例2 代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>固定宽度 相对定位</title>
<style type="text/css">
body{
background:#fff;
font:13px/1.5 Arial, Helvetica, sans-serif;
margin:0;
padding:0;
}
.rounded{
background:#aaa url(images/lt.gif) top left no-repeat;
width:100%;
}
.rounded h2{
background:url(images/rt.gif) top right no-repeat;
padding:20px 20px 10px;
margin:0;
}
.rounded .main{
background:url(images/r.gif) top right repeat-y;
padding:10px 20px;
margin:-2em 0 0 0;
}
.rounded .footer{
background:url(images/lb.gif) bottom left no-repeat;
}
.rounded .footer p{
color:#888;
text-align:right;
background:url(images/rb.gif) bottom right no-repeat;
display:block;
padding:10px 20px 30px;
margin:-2em 0 0 0;
}
#header,#pagefooter,#containter{
width:760px;
margin: 0 auto;
}
#content{
position:relative;
margin-left:62px;
width:260px;
float:left;
}
#content1{
position:relative;
top:20px;
width:497px;
float:left;
}
#side{
/*position:absolute;*/
width:260px;
float:left;
}
#side2{
width:497px;
}
</style>
</head>
<body>
<div id="header">
<div class="rounded">
<h2>Page Header</h2>
<div class="main">
<p>
这是一行文本,这里作为样例,显示在布局框中<br />
这是一行文本,这里作为样例,显示在布局框中
</p>
</div>
<div class="footer">
<p>
查看详细信息
</p>
</div>
</div>
</div>
<div id="containtert">
<div id="content">
<div class="rounded">
<h2>Page Content</h2>
<div class="main">
<p>
这是一行文本,这里作为样例,显示在布局框中<br />
这是一行文本,这里作为样例,显示在布局框中
</p>
</div>
<div class="footer">
<p>
查看详细信息
</p>
</div>
</div>
</div>
<div id="content1">
<div class="rounded">
<h2>Page Content1</h2>
<div class="main">
<p>
这是一行文本,这里作为样例,显示在布局框中<br />
这是一行文本,这里作为样例,显示在布局框中
</p>
</div>
<div class="footer">
<p>
查看详细信息
</p>
</div>
</div>
</div></div>
<div id="containter">
<div id="side">
<div class="rounded">
<h2>Page Side</h2>
<div class="main">
<p>
这是一行文本,这里作为样例,显示在布局框中<br />
这是一行文本,这里作为样例,显示在布局框中
</p>
</div>
<div class="footer">
<p>
查看详细信息
</p>
</div>
</div></div>
<div id="side2">
<div class="rounded">
<h2>Page Side</h2>
<div class="main">
<p>
这是一行文本,这里作为样例,显示在布局框中<br />
这是一行文本,这里作为样例,显示在布局框中
</p>
</div>
<div class="footer">
<p>
查看详细信息
</p>
</div>
</div>
</div></div>
</div>
<div id="pagefooter">
<div class="rounded">
<h2>Page Footer</h2>
<div class="main">
<p>
这是一行文本,这里作为样例,显示在布局框中<br />
这是一行文本,这里作为样例,显示在布局框中
</p>
</div>
<div class="footer">
<p>
查看详细信息
</p>
</div>
</div>
</div>
</body>
</html>

浙公网安备 33010602011771号