码迷,mamicode.com
首页 > Web开发 > 详细

CSS 经典三列布局

时间:2017-04-10 23:31:53      阅读:313      评论:0      收藏:0      [点我收藏+]

标签:break   back   position   ade   bre   java   inner   头部   nbsp   

一 圣杯布局

1 html结构

<!DOCTYPE html>
<html>
<head>
	<title></title>
	<link rel="stylesheet" type="text/css" href="css/css.css">
</head>
<body>
	<div class="header">头部</div>
	<div class="container">
		<div class="middle">中间</div>
		<div class="left">左侧</div>
		<div class="right">右侧</div>
	</div>
	<div class="footer">底部</div>
</body>
</html>

2 css

*{padding: 0;margin: 0;list-style: none;}
body{min-height: 700px;}
.header,.footer{background: #ff9999;text-align: center;height: 50px;line-height: 50px;}
.left,.middle,.right{
	position: relative;
	float: left;
	min-height: 530px;
	line-height: 530px;
	text-align: center;
}
.container{
	padding: 0 220px 0 200px;
	overflow: hidden;
}
.left{
	margin-left: -100%;left: -200px;
	width: 200px;
	background-color: #99ffff;
}
.right{
	margin-left: -220px;
	right: -220px;
	width: 220px;
	background: #ccff99;
}
.middle{
	width: 100%;
	background: #ccffff;
	word-break: break-all;
}
.footer{
	clear: both;
}

 

二 双飞翼布局

1 html结构

<!DOCTYPE html>
<html>
<head>
	<title></title>
	<link rel="stylesheet" type="text/css" href="css/sb.css">
</head>
<body>
	<div class="header">header</div>
	<div class="middle">
		<div class="middle-inner">middle</div>
	</div>
	<div class="left">left</div>
	<div class="right">right</div>
	<div class="footer">footer</div>
</body>
</html>

2 css

*{padding: 0px;margin: 0px;}
.header,.footer{
	height: 50px;
	line-height: 50px;
	background: #cf9999;
    border: 1px solid #333;
    text-align: center;
}

.left,.middle,.right{
	float: left;
	min-height: 500px;
	line-height: 500px;
	text-align: center;
}
.left{
	margin-left: -100%;
	width: 200px;
	background: #9999ff;
}
.right{
	margin-left: -220px;
	width: 220px;
	background: #ccffff;
}
.middle{
	width: 100%;
	
}
.middle-inner{
	margin-left: 200px;
	margin-right: 220px;
	min-height: 500px;
	background-color: #ccff99;
	word-break: break-all;
}
.footer{clear: both;}

  

三 以上两种 经典布局以双飞翼为最佳,在此基础上进行各种变种,主要体现了浮动和margin负值的巧妙使用

 

CSS 经典三列布局

标签:break   back   position   ade   bre   java   inner   头部   nbsp   

原文地址:http://www.cnblogs.com/rjjs/p/6691280.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!