Blogger Information
Blog 24
fans 0
comment 1
visits 14820
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0327课后作业
张成钢的博客
Original
676 people have browsed it

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>经典的三列圣杯布局</title>
	<style type="text/css">
		div {
			text-align: center;
			color: red;
		}
		.header,.footer {
				width: 100%;
				height: 60px;
				background-color: lightgray;
				}

		.content {
				width: 1000px;
				min-height: 100%;
				background-color: gray;
				margin: auto;
				line-height: 60px;
				}

		.footer {clear: both;}

		.container {
			width: 700px;
			margin: auto;
			background-color: yellow;
			overflow: hidden;
			padding: 0px 150px;
		}

		.main,.left,.right {
			min-height: 450px;
			float: left;
		}
		.container .main {
			width: 100%;
			background-color: skyblue;
		}

		.container .left {
			width: 150px;
			background-color: lightgreen;
			margin-left: -100%;
			position: relative;
			left: -150px;
		}

		.container .right {
			width: 150px;
			background-color: wheat;
			margin-left: -150px;
			position: relative;
			right: -150px;		
		}	

	</style>
</head>
<body>

	<div class="header">
		<div class="content">网站头部</div>
	</div>

	<!-- 主体 -->
	<div class="container">
		<div class="main">主体</div>
		<div class="left">左侧</div>
		<div class="right">右侧</div>
	</div>

	<!-- 底部 -->
	<div class="footer">
		<div class="content">网站底部</div>
	</div>

<pre>
		三列圣杯布局原理:
		1.创建大容器,居中;
		2.三区块 main + left +right = 总宽,main left right 顺序不能错;
		3.三区块 全部float:left;
		4.left区块定位 margin-left:-100%, right区块定位:margin-left:-150px
		5.main添加内边距=left right 区块宽度,挤压;
		6.区块left相对移动 左-150px  right相对移动右-150px

</pre>


</body>
</html>

运行实例 »

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

0327-1.png0327-2.png

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>经典的三列双飞翼布局</title>
	<style type="text/css">
		div {
			text-align: center;
			color: red;
		}
		.header,.footer {
			width: 100%;
			height: 60px;
			background-color: lightgray;
		}

		.footer {clear: both;}

		.content {
			width: 1000px;
			min-height: 100%;
			background-color: gray;
			margin: auto;
			line-height: 60px;
		}

		.container {
			width: 1000px;
			margin: auto;
			background-color: yellow;
		}

		.wrap {
			width: 100%;
			float: left;
			background-color: cyan;
			/*margin: 0 200px;*/
		}

		.left ,.right ,.main {
			min-height: 600px;
		}

		.main {
			margin: 0 200px;
			background-color: #fff;			
		}

		.left , .right {
			width: 200px;
			float:left;
		}

		.left {
			background-color: skyblue;
			margin-left:-100%;
		}

		.right {
			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="main">主体</div>
		</div>
		<div class="left">左侧</div>
		<div class="right">右侧</div>
	</div>

	<!-- 底部 -->
	<div class="footer">
		<div class="content">网站底部</div>
	</div>

	<pre>
		双飞翼布局原理:
		1.创建大容器,居中;
		2.创建三列结构;
			2.1 主体 左 右 顺序不能错;
			2.2 主体列必须套父块main,加样式;
			2.3 父块main宽度100%,左left 右right 列定宽;
		3.设置main/left/right 左浮动;(理解左浮动原理)
		4.设置left margin-left:-100% 左缩进
		5.设置right margin-left:-200px 左缩进
		6.main左右外边距 200px
	</pre>

</body>
</html>

运行实例 »

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


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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!