圣杯布局
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.container{
overflow: hidden;
padding: 0 100px;
}
.middle{
width: 100%;
height: 200px;
background-color: aquamarine;
float: left;
}
.left{
position: relative;
left: -200px;
margin-left: -100%;
width: 200px;
height: 200px;
background-color: blueviolet;
float: left;
}
.right{
position: relative;
right: -200px;
margin-left: -200px;
width: 200px;
height: 200px;
background-color: blue;
float: left;
}
</style>
</head>
<body>
<div class="container">
<div class="middle">sssxcwwwwwwsssss中间区域</div>
<div class="left">左边区域</div>
<div class="right">右边区域</div>
</div>
</body>
</html>

双飞燕布局
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div class="wrapper">
<div class="main">
<div class="inner">
main
</div>
</div>
<div class="left">left</div>
<div class="right">right</div>
</div>
<style>
.main,.left,.right{
height: 100px;
float: left;
}
.main{
width: 100%;
background-color: aqua;
}
.left{
width:120px;
margin-left: -100%;
background-color:cornflowerblue;
}
.right{
width: 120px;
margin-left: -120px;
background-color: cadetblue;
}
.inner{
margin-left:120px;
margin-right: 120px;
}
</style>
</body>
// 双飞燕布局少了定位,就是在中间的div多嵌套了一个div,利用margin的属性去控制,相对于圣杯布局简洁了不少
网友评论