10、css定位

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			/* 
			 相对定位 relative:相对于原来在文档流的位置进行偏移
			 
			 绝对定位: 根据已经进行定位的父级元素进行偏移
			 注意点:通常在使用决定定位时  会将腹肌元素设置为相对定位
			 
			 
			 
			 固定位置定位
			 
			 */
			.box11{
				height: 200px;
				position: relative;
				background: yellowgreen;
			}
			
			.box1,
			.box2,
			.box3 {
				height: 200px;
				width: 200px;
	
				margin-left: 20px;

			}

			.box1 {
				background: #00FFFF;
				position: fixed;
				left: 20px;
				top: 100px;
			}

			.box2 {
				background: yellow;
				/* position: relative; */
				position: absolute;
				left: 200px;
				top: 50px;
			}

			.box3 {
				background: red;
			}
			#app{
				position: relative;
				height: 2000px;
			}
			
			.left,.right{
				height: 50px;
				width: 20px;
				background: blue;
			}
			.left{
				position: absolute;
				left: 20px;
				top: 40%;
			}
			.right{
				position: absolute;
				right: 20px;
				top: 40%;
			}
		</style>
	</head>
	<body>
		<div class="box11">
			<div class="left"></div>
			<div class="right"></div>
			
			
		</div>
		
		<div id="app">
			<div class="box1">
				1111
			</div>
			<div class="box2">
				222
			</div>
			<div class="box3">
				3333
			</div>

			<div class="clear"></div>

		</div>



	</body>
</html>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值