Blogger Information
Blog 56
fans 3
comment 1
visits 50770
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
css三列布局-2018年3月28日13时10分
沈斌的博客
Original
726 people have browsed it

css双飞翼布局,使用了float,margin,中间主体用div wrap包裹,margin left margin right确定主体。

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>bird layout</title>
	<style type="text/css">
		.header,.footer {
			width: 100%;
			height: 60px;
			background-color: lightgrey;
		}
		.content {
			width:1000px; 
			min-height: 100%;
			
			margin: auto;

			text-align: center;
			line-height: 60px;

			background-color: grey;
			
			
		}
		.footer {
			clear: both;
		}

		.container {
			width: 1000px;
			margin: auto;
			background-color: yellow;
			overflow: hidden;
		}
		
		.wrap {
			width: 100%;
			background: cyan;
			float: left;
		}
		.middle {
			
			min-height: 600px;
			margin: 0 200px;
			
			border: 1px solid black;
			
			

		}
		.left{
			width: 200px;
			min-height: 600px;
			float: left;
			background-color: lightblue;

			margin-left:-100%;
		}
		.right {
			width: 200px;
			min-height: 600px;
			float: left;
			background-color: lightgreen;

			margin-left: -200px;
		}
	</style>
</head>
<body>
	<div class="header">
		<div class="content">网站顶部</div>
	</div>
	<div class="container">
		<div class="wrap">
			<div class="middle">中部</div>
		</div>
		
		<div class="left">左边</div>
		<div class="right">右边</div>
	</div>
	<div class="footer">
		<div class="content">网站底部</div>
	</div>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


css圣杯布局,使用了float,margin,使用绝对定位确定中间主体。

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>cup layout</title>
	<style type="text/css">
		.header,.footer {
			width: 100%;
			height: 60px;
			background-color: lightgrey;
		}
		.content {
			width:1000px; 
			min-height: 100%;
			
			margin: auto;

			text-align: center;
			line-height: 60px;

			background-color: grey;
			
			
		}
		.footer {
			clear: both;
		}
		
		.container {
			width: 600px;
			background-color: yellow;
			/*父容器及内部区块水平居中*/
			margin: auto;
			overflow: hidden;

			padding: 0 200px;

		}

		.container .middle {
			min-height: 650px;
			width: 100%;
			float: left;
			background-color: lightgreen;
		}

		.container .left {
			width: 200px;
			min-height: 650px;
			float: left;
			background-color: lightskyblue;
			margin-left: -100%;

			position: relative;
			left: -200px;
		}

		.container .right {
			width: 200px;
			min-height: 650px;
			float: left;
			background-color: wheat;
			margin-left: -200px;

			position: relative;
			right: -200px;
		}
	</style>
</head>
<body>
	<div class="header">
		<div class="content">网站顶部</div>
	</div>
	<div class="container">
		<div class="middle">中部</div>
		
		<div class="left">左边</div>
		<div class="right">右边</div>
	</div>
	<div class="footer">
		<div class="content">网站底部</div>
	</div>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

总结:

双飞翼布局主体多了一层div标签,圣杯布局多了css属性设置。两种布局都使用了float属性,margin-left属性。

双飞翼布局,圣杯布局容器container设置的width不同,导致后面处理main也不同。



手抄

layout1.JPG

layout2.JPG

cup.png

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post