前端自适应布局方法总结

一,一栏固定一栏自适应

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{margin:0;padding:0;}
#left{
height: 600px;
width:200px;
float:left;
background-color: green;
}
#main{
height: 600px;

background-color:yellow;
}

</style>
</head>
<body>
<div id="left">固定宽度</div>
<div id="main">自适应宽度</div>
</body>
</html>

二, 左右固定  中间自适应

 

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{margin:0;padding:0;}
#left{
height:300px;
width:200px;
position: absolute;
background-color: green;
}
#right{

float: right;
height:300px;
width:200px;
background-color: green;
}
#main{
height: 600px;
position: absolute;
left: 200px;
right:200px;
background-color:yellow;
}

</style>
</head>
<body>
<div id="left">左边固定</div>
<div id="main">中间自适应宽度</div>
<div id="right">右边固定</div>
</body>
</html>

posted on 2017-10-27 23:20  前端小白001  阅读(5097)  评论(0编辑  收藏  举报