圣杯布局
<!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>
.parent {
overflow: hidden;
padding: 0 100px;
}
.middle {
float: left;
height: 100px;
width: 100%;
background-color: green;
}
.left {
/* 以便申明 left 属性 */
position: relative;
/* 移出当前界面,注意和 parent 中的 padding-left 配合正好 */
left: -100px;
float: left;
height: 100px;
width: 100px;
background-color: red;
/* 上移一行 */
margin-left: -100%;
}
.right {
position: relative;
right: -100px;
float: left;
height: 100px;
width: 100px;
background-color: blue;
/* 上移到上一行末尾 */
margin-left: -100px;
}
</style>
</head>
<body>
<div class="parent">
<div class="middle">Middle</div>
<div class="left">Left</div>
<div class="right">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>
<style>
.parent{
overflow: hidden;
}
.middle{
width: 100%;
float: left;
}
.inner-middle{
height: 100px;
margin: 0 100px;
background: steelblue;
}
.left{
width: 100px;
height: 100px;
background: yellowgreen;
float: left;
margin-left: -100%;
}
.right{
width: 100px;
height: 100px;
background: hotpink;
float: left;
margin-left: -100px;
}
</style>
</head>
<body>
<div class="parent">
<div class="middle">
<div class="inner-middle">
Middle
</div>
</div>
<div class="left">Left</div>
<div class="right">Right</div>
</div>
</body>
</html>
来源:CSDN
作者:weixin_41424721
链接:https://blog.csdn.net/weixin_41424721/article/details/103862480