HTML5学习_day05(5)--html之float元素的规则



<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>浮动元素的细则</title>
		<style type="text/css">
			
			div{
				width: 400px;
				height: 400px;
				background-color: aqua;
				
			}
			p{
				width: 300px;
				height: 300px;
				background-color: salmon;
				position:;
				float: left;
			}
			.wrap{
				width: 399px;  /*空间不足时就会换行 400px就不用换行*/
				height: 400px;
				background: olive;
			}
			.class1{
				width: 100px;
				height: 100px;
				background-color: wheat;
			}
			.class2{
				width: 100px;
				height: 100px;
				background-color: slateblue;
			}
			.class3{
				width: 100px;
				height: 100px;
				background-color: brown;
			}
			.class4{
				width: 100px;
				height: 100px;
				background-color: cornflowerblue;
			}
			.wrap div{
				float: left;
			}
			.wrap1{
				width: 800px;  
				height: 400px;
				background: olive;
			}
			.class5{
				width: 700px;
				height: 100px;
				background-color: wheat;
				float: left;
			}
			.class6{
				width: 100px;
				height: 100px;
				background-color: slateblue;
				float: left;
			}
			.class7{
				width: 100px;
				height: 100px;
				background-color: brown;
				float: right;
			}
			.class8{
				width: 100px;
				height: 100px;
				background-color: salmon;
				float:right;
			}
		</style>
	</head>
	<body>
		<!--1.浮动框不能在其浮动方向上一处包含块(例子包含块就是div)
		浮动元素左浮,其左边界不能超出包含块的左边界
		浮动元素右浮,其右边界不能超出包含块的右边界
		<div class="div">
			<p class="p">我是浮动元素</p>
		</div>-->
		<!--2.浮动框的定位会受同向浮动框的影响
		也就是说:当前浮动元素的定位会收到之前生成的浮动框的影响,他们不会相互遮拦,当前浮动框会紧挨着之前的浮动框的左边界进行定位。
                   如果当前空间不足,则会换行,否则就会放置在之前浮动框下面.
		<div class="wrap">
			<div class="class1"></div>
			<div class="class2"></div>
			<div class="class3"></div>
			<div class="class4"></div>
		</div>-->
		3.浮动框与不同方向浮动框不可以重叠
		解释:同一行中不同方向的浮动框不能有互相重叠的现象
		<div class="wrap1">
			<div class="class5"></div>
			<div class="class6"></div>
			<div class="class7"></div>
			<div class="class8"></div>
		</div>
		4.浮动框的边界不能超出包含块的边界
	</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值