全屏布局,多应用在系统页面中,其核心是导航部分固定宽度,中间内容多是自适应。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.container{
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
padding: 0 200px 0 300px;
}
.left{
width: 300px;
height: 100%;
background: red;
position: absolute;
top:0;
left: 0;
}
.center{
width: 100%;
height: 100%;
background: green;
}
.right{
width: 200px;
height: 100%;
background: pink;
position: absolute;
top:0;
right: 0;
}
</style>
</head>
<body>
<div class="container">
<div class="left"></div>
<div class="center"></div>
<div class="right"></div>
</div>
</body>
</html>
圣杯布局
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>圣杯布局</title>
<style type="text/css">
.container{
min-width:300px;
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
padding:0 200px 0 300px;
}
.container .main{
float:left;
width:100%;
height:100%;
background-color:black;
}
.container .left{
float:left;
width:300px;
height:100%;
margin-left:-100%;
position:relative;
left:-300px;
background-color:red;
}
.container .right{
float:left;
width:200px;
height:100%;
margin-left:-200px;
position:relative;
right:-200px;
background-color:green;
}
</style>
</head>
<body>
<div class="container">
<div class="main"></div>
<div class="left"></div>
<div class="right"></div>
</div>
</body>
</html>