圣杯布局:
是指三行三列布局上下定宽 中间分三列左右定宽 中部自适应
主要实现中间主题部分中的左右定宽+中间自适应的布局效果
例如:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>圣杯布局一</title>
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<style>
#parent{
height: 300px;
margin-left: 300px;
margin-right: 300px;
}
#left,#center,#right{
height: 300px;
float: left;
}
#left,#right{
/*定宽*/
width: 300px;
}
#left{
background-color: #c9394a;
/**当前元素从当前行移动上一行同一个位置*/
margin-left: -100%;
position: relative;
/**将元素移动理想位置*/
left: -300px;
}
#center{
width: 100%;
background-color: green;
}
#right{
background-color: #cccccc;
margin-left: -300px;
position: relative;
right: -300px;
}
</style>
</head>
<body>
<div id="parent">
<!--搜素引擎的友好-->
<div id="center"></div>
<div id="left">左:定宽</div>
<div id="right">右:定宽</div>
</div>
</body>
</html>
示例图