CSS--浮动(一行两列,三行三列)

目录

浮动属性:

一行两列

三行三列


浮动属性:

作用:控制页面元素脱离原有文档流,实现向左或向右 移动, 直到该元素外 边缘 碰到其包含 框或另一个浮动框的 边缘停止, 标准流中的其他盒子将顶到浮动盒子的位置 。浮动的元素不占据实际空间。
属性 float
取值
none :表示对象不 浮动,默认值
left :对象向左浮动
right :对象向右浮动

一行两列

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>1行2列</title>
		<style>
			*{
				margin: 0px;
				padding: 0px;
			}
			#container{
				height: 500px;
				width: 900px;
				margin: 0 auto;
			}
			#aside{
				width: 200px;
				height: 500px;
				background-color: black;
				float: left;
			}
			#content{
				width: 695px;
				height: 500px;
				background-color: blue;
				float: right;
			}
		</style>	
	</head>
	<body>
		<div id="container">
			<div id ="aside"></div>	
			<div id="content"></div>
		
		</div>

	</body>
</html>

 

三行三列

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>2行3列</title>
		<style>
			*{
				margin: 0px;
				padding: 0px;
			}
			#container{
				height: 500px;
				width: 650px;
				margin: 0 auto;
			}
			#header{
				color: #000000;
				height: 100px;
				background-color: red;
				margin-bottom: 5px;
			}
			#aside1{
				width: 20%;
				height: 400px;
				background-color: black;
				float: left;
			}
			#aside2{
				width: 20%;
				height: 400px;
				background-color: cyan;
				
				float: left;
			}
			#content{
				width: 60%;
				height: 400px;
				background-color: green;
				float: left;
				margin-bottom: 5px;
			}
			
			#footer{
				height: 100px;
				background-color: yellow;
				clear: both;
			}
			
		</style>		
		
	</head>
	<body>
		<div id="container">
			<div id="header"></div>
			<div id="aside1"></div>
			<div id="aside2"></div>
			<div id="content"></div>
			<div id="footer">
			</div>
		</div>
		
	</body>
</html>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

ML.star

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

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

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

打赏作者

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

抵扣说明:

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

余额充值