DIV+CSS布局第一部分,一列布局,两列布局,三列布局以及组合布局举例说明

DIV+CSS布局一


一列布局:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>布局</title>
		<style type="text/css">
			body,h1{margin: 0;padding: 0;}
			.header{background-color: #000;
			color: #FFF;
			text-align: center;}
			.main{
				background-color: #666;
				color: #fff;
				margin: 0 auto;
				width:80%;
				height: 700px;
				text-align: center;
				
			}
			.foot{
				background-color: #000;
				color: #fff;
				margin: 0 auto;
				width:80%;
				height: 150px;
				text-align: center;
				
			}
		</style>
	</head>
	<body>
		<div class="header"><h1>页面头部信息</h1></div>
		<div class="main"><h1>页面主要内容</h1></div>
		<div class="foot"><h1>版权信息</h1></div>
	</body>
</html>

运行结果如下:


两列布局

代码如下:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>两列布局</title>
		<style type="text/css">
			body,h1{margin: 0;padding: 0;}
			.left{
				float: left;
				width: 30%;
				background-color: black;
				color: green;
				height: 300px;
			}
			.right{
				float: right;
				width: 70%;
				background-color: white;
				height: 300px;
				color: red;
			}
			.main{width: 90%;
			margin: 0 auto;
			text-align: center;
			}
		</style>
	</head>
	<body>
		<div class="main">
		<div class="left">LOGO</div>
		<div class="right">用户信息</div>
		</div>
	</body>
</html>

运行效果:


三列布局

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>三列布局</title>
		<style type="text/css">
			body,h1{margin: 0;padding: 0;}
			.left{
				float: left;
				width: 20%;
				background-color: black;
				color: green;
				height: 300px;
			}
			.right{
				float: right;
				width: 30%;
				background-color: green;
				height: 300px;
				color: red;
			}
			.middle{
				float: left;
				width: 50%;
				background-color: yellow;
				height: 300px;
				color: gray;
			}
			.main{width: 90%;
			margin: 0 auto;
			text-align: center;
			}
		</style>
	</head>
	<body>
		<div class="main">
		<div class="left">左边</div>
		<div class="middle">中间信息</div>
		<div class="right">右边</div>
		</div>
	</body>
</html>

运行结果如下:


综合布局

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			body,h1{margin: 0; padding: 0;color: gray;text-align: center;}
			.top{
				background: yellowgreen;
				width: 100%;
				height: 100px;
			}
			.top_main{
				margin: 0 auto;
				background: #000;
				width: 900px;
				height: 100px;
			}
				.top_left{
				float: left;
				background:gold;
				width: 200px;
				height: 100px;
			}
			.top_right{
				float: right;
				background: #00C;
				width: 700px;
				height: 100px;
			}
			.nav{
				margin: 0 auto;
				background: #999;
				width: 900px;
				height: 50px;
			}
						.left{
				float: left;
				width: 300PX;
				background-color: black;
				color: green;
				height: 300px;
			}
			.right{
				float: right;
				width: 300PX;
				background-color: green;
				height: 300px;
				color: red;
			}
			.middle{
				float: left;
				width: 300PX;
				background-color: yellow;
				height: 300px;
				color: gray;
			}
			.main{width: 900PX;
			margin: 0 auto;
			height: 500px;
			background-color: peachpuff;
			}
			.footer{
				margin: 0 auto;
				background-color: #000;
				width: 900px;
				height: 200px;
				color: #FFF;
			}
		</style>
	</head>
	<body>
		<div class="top">
			<div class=top-main>
				<div class="top_left"><h1>logo</h1></div>
				<div class="top_right"><h1>头部信息</h1></div>
			</div>
		</div>
		<div class="nav"><h1>页面导航</h1></div>
		<!--主要内容-->
		<div class="main">
		<div class="left">左边</div>
		<div class="middle">中间信息</div>
		<div class="right">右边</div>
		</div>
		<!--版权信息-->
		<div class="footer"><h1>版权信息</h1></div>
	</body>
</html>
运行结果如下:



  • 10
    点赞
  • 39
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

熊猫_water

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值