页面布局
圣杯布局
1.设置三个盒子,左侧固定,右侧固定,中间自适应,都设置浮动,中间先解析
2.左侧盒子,margin-left:-100%,右侧盒子设置,margin-left: -本身宽度
3.给父标签设置内边距,然后给左右两侧设置定位移动
圣杯布局缺点:当中间部分宽度小于左侧部分宽度时,布局会混乱
<style>
* {
padding: 0;
margin: 0;
}
.center {
width: 100%;
height: 400px;
background-color: red;
float: left;
}
.left {
width: 200px;
height: 400px;
background-color: blue;
float: left;
margin-left: -100%;
position: relative;
left: -200px;
}
.right {
width: 300px;
height: 400px;
background-color: gold;
float: left;
margin-left: -300px;
position: relative;
left: 300px;
}
.clearfix::after{
content: "";
display: block;
clear: both;
}
.wrap {
padding: 0 300px 0 200px;
}
</style>
</head>
<body>
<div class="wrap clearfix">
<div class="center">center</div>
<div