3.27

烟火的博客
烟火的博客原创
2018年04月08日 10:16:50664浏览

实例

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

	.footer {
		clear: both;
	}

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

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

	.container .main {
		/*先设置行高暂时填充*/
		min-height: 650px;
		/*设置100%的宽度,避免被挤*/
		width: 100%;
		float:left;
		background-color: lightgreen; 
	}

	.container .left {
		width: 200px;
		/*最小高度,设置为行高一致*/
		min-height: 650px;
		float:left;
		margin-left: -100%;

		/*设置相对定位*/
		position: relative;
		right: 200px;
		background-color: red; 

	}

	.container .right {
		width: 200px;
		min-height: 650px;
		float:left;
		margin-left:-200px;
		position: relative;
		right:-200px;
		background-color: blue;
	}
	</style>
</head>
<body>
<!-- Html的DOM结构 -->
<!-- 头部 -->
<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>
</body>
</html>

运行实例 »

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


声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议