前端开发_HTML5_布局-div+css布局

div + css布局

1.引入

   我们之前学习了两种排版,分别是表格布局和流式布局,那么我们发现这俩中排版都有自己的局限性,那么下面呢,我们就一起来学习一个比较重要的布局css+div布局。这一种布局方式是基于盒子模型的一种布局方式,在实际的开发中使用的比较多。

2.div+css布局

   css+div布局是一种重要的布局方式,可以按照不同的排版方式实现不同效果的页面布局。

3.div+css布局

   (1).简单的上中下结构布局

<style type="text/css">
   body{
	 font-size: 25px;
	 font-family: "宋体";
	 color: #0000ff;
	 text-align: center;
   }
			
   .containner{
	  margin: 0 auto;
	  height: 900px;
	  width: 1200px;
	  padding: 10px;
	  background-color: #bfbfbf;
	}
			
   .containner .head{
	  height: 180px;
	  background-color: #00AA00;
	  margin-bottom: 10px;
	}
   .containner .content{
	  height: 600px;
	  background-color: #b90000;
	  margin-bottom: 10px;
   }
			
   .containner .foot{
	  height: 100px;
	  background-color: #55ff00;
	  margin-bottom: 10px;
   }
			
</style>
<div class="containner">
   <div class="head">
	  这是头部
   </div>
   <div class="content">
	  这是内容
   </div>
   <div class="foot">
	  这是底部
   </div>
</div>

  (2).简单的上左中(窄)右宽(宽)下结构布局

<style type="text/css">
			body{
				font-size: 25px;
				font-family: "宋体";
				color: #0000ff;
				text-align: center;
			}
			
			.containner{
				margin: 0 auto;
				height: 900px;
				width: 1200px;
				padding: 10px;
				background-color: #bfbfbf;
			}
			
			.containner .head{
				height: 180px;
				background-color: #00AA00;
				margin-bottom: 10px;
			}
			.containner .content{
				height: 600px;
				margin-bottom: 10px;
			}
		    .content-left{
				float: left;
				height: 600px;
				width: 300px;
				background-color: #b90000;
				margin-bottom: 10px;
			}
			.containner .content .content-right{
				float: right;
				height: 600px;
				width: 890px;
				background-color: #ff5500;
				margin-bottom: 10px;
			}
			
			.containner .foot{
				height: 100px;
				background-color: #55ff00;
				margin-bottom: 10px;
			}
</style>

<body>
	<div class="containner">
			<div class="head">
				这是头部
			</div>
			<div class="content">
				<div class="content-left">
					导航
				</div>
				<div class="content-right">
					详细内容
				</div>
			</div>
			<div class="foot">
				这是底部
			</div>
    </div>
</body>

   (3).简单的上中(左中右)下结构布局

<style type="text/css">
			body{
				font-size: 25px;
				font-family: "宋体";
				color: #0000ff;
				text-align: center;
			}
			
			.containner{
				margin: 0 auto;
				height: 900px;
				width: 1200px;
				padding: 10px;
				background-color: #bfbfbf;
			}
			
			.containner .head{
				height: 180px;
				background-color: #00AA00;
				margin-bottom: 10px;
			}
			.containner .content{
				height: 600px;
				margin-bottom: 10px;
			}
		    .content-left{
				float: left;
				height: 600px;
				width: 300px;
				background-color: #b90000;
				margin-bottom: 10px;
			}
			.content-center{
				float: left;
				height: 600px;
				width: 590px;
				background-color: #4c7300;
				margin-bottom: 10px;
				margin-left: 10px;
			}
			
		    .content-right{
				float: right;
				height: 600px;
				width: 290px;
				background-color: #ff5500;
				margin-bottom: 10px;
				margin-left: 10px;
			}
			
			.containner .foot{
				height: 100px;
				background-color: #55ff00;
				margin-bottom: 10px;
			}
</style>
<body>
		<div class="containner">
			<div class="head">
				这是头部
			</div>
			<div class="content">
				<div class="content-left">
					内容左
				</div>
				<div class="content-center">
					内容中
				</div>
				<div class="content-right">
					内容右
				</div>
			</div>
			<div class="foot">
				这是底部
			</div>
		</div>
</body>

上述给出的是几种常见的div布局,我们还可以根据客户的需求设计出更多的按照实际要求的内容,但是无论如何设计,我们只要抓住一点就是使用块级结构div产生的盒子进行页面内容的布局即可完成。 

  • 6
    点赞
  • 53
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

魔笛手7

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

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

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

打赏作者

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

抵扣说明:

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

余额充值