一、两栏布局
1、清样式、设置html高度
*{
margin:0;
padding:0;
}
html,body{
height:100%;
}
2、设置两个div
方案1:margin-left
<style>
.box1{
width:200px;
height:100%;
background:red;
float:left;
}
.box2{
height:100%;
background:yellow;
margin-left:200px;
}
</style>
<body>
<div class="box1"></div>
<div class="box2"></div>
</body>
方案2:calc(100% - 200px)
<style>
.box1{
width:200px;
height:100%;
background:red;
float:left;
}
.box2{
height:100%;
width:calc(100% - 200px);
background:yellow;
float:left;
}
</style>
<body>
<div class="box1"></div>
<div class="box2"></div>
</body>
二、三栏布局
1、清样式、设置html高度
*{
margin:0;
padding:0;
}
html,body{
height:100%;
}
2、设置div
上、中(左、中、右)、下布局
<style>
.top,.bottom{
width:100%;
height:50px;
background:gray;
}
.middle{
width:100%;
height:calc(100% - 100px);
}
.left,.right{
width:100px;
height:100px;
background:red;
}
.center{
width:calc(100% - 200px);
height:100%;
background:blue;
float:left;
}
</style>
<body>
<div class="top"></div>
<div class-"middle">
<div class="left"></div>
<div class="center"></div>
<div class="right"></div>
</div>
<div class="bottom"></div>
</body>