首页 > 代码库 > 多栏布局

多栏布局

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style >
.content{
padding:0px;
margin:0px;
border:red 1px solid;
position:absolute;
top:0px;
bottom:0px;
height:100%;
width:100%;
overflow-y:scroll;
}
.top{
position:relative;
border:#ccc 1px solid;

}
.left{
height:200px;
width:300px;
background:green;
float:left;
}
.right{
height:200px;
/* width:200px;*/
margin-left:300px;
background:pink;
position:relative;
}
.middle{
position:relative;
margin-top:30px;
overflow:hidden;
border:red 1px solid;
}
.left_1{
height:200px;
width:auto;
background:pink;
margin-right:300px;
}
.right_1{
width:300px;
height:200px;
background:green;
position:absolute;
right:0px;
top:60px;
}
.left_21{
height:200px;
width:300px;
background:green;
float:left;
}
.left_22{
height:200px;
width:300px;
margin-left:300px;
background:blue;
position:absolute;
}
.right_21{
height:200px;
background:pink;
position:relative;
right:0px;
margin-left: 600px;
}
.left_31{
height: 200px;
width: 300px;
background: green;
float: left;
}
.left_32{
height: 200px;
background: pink;
margin-left: 300px;
margin-right: 300px;
}
.right_3{
height: 200px;
width: 300px;
background: green;
position: absolute;
right: 0px;
top: 60px;
}
</style>
</head>

<body>
<div class="content">

<div class="top">
<h3>左边固定右边自适应</h3>
<div class="left"></div>
<div class="right"></div>
</div>
<div class="middle">
<h3>右边固定,左边自适应</h3>
<div class="left_1"></div>
<div class="right_1"></div>
</div>
<div class="middle">
<h3>左边两个div固定大小,右边自适应</h3>
<div class="left_21"></div>
<div class="left_22"></div>
<div class="right_21"></div>
</div>
<div class="middle">
<h3>左右两个div固定大小,中间自适应</h3>
<div class="left_31"></div>
<div class="left_32"></div>
<div class="right_3"></div>
</div>
</div>
</body>
</html>

总结:多栏布局更多的适用于左侧导航栏固定的场景,比之前讲的圣杯布局写法更简单,实现的效果是一样的。

多栏布局