CSS初探学习总结提高 四

定位布局,让标签固定到想要的位置

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>定位布局</title>
	<style type="text/css">
		* {
			margin: 0;
			padding: 0;
		}
		ul {
			list-style: none;
		}
		
		fieldset {
			margin: 20px 10px;
		}
		ol {
			margin: 0 20px;
		}
		
		.backView {
			width: 613px;
			height: 230px;
			margin: 0 auto;	
			position: relative;
			background-color: pink;
		}
		.leftB,
		.rightB {
			top: 50%;
			margin-top: -18px;
			position: absolute;
		}
		.rightB {
			right: 0;
		}
		.circle {
			width: 65px;
			height: 15px;
			background: rgba(255,255,255,0.4);
			position: absolute;
			bottom: 20px;
			left: 50%;
			margin-left: -32PX;
			border-radius: 6px;
		}
		.circle li {
			width: 9px;
			height: 9px;
			background-color: #B7B7B7;
			border-radius: 50%;
			float: left;
			margin: 2px;
		}
		.circle .current {
			background-color: #f40;
		}
	</style>
</head>
<body>
	<fieldset>
		<legend>定位布局,定位布局后,就有行内块元素的特征</legend>
		<ol>
			<li>
				静态定位 position: static;
				<ol>
					<li>静态定位 -- 对于边偏移无效的</li>
					<li>一般他用来 清除定位的。 一个原来有定位的盒子,不想加定位了,就写这句话</li>
				</ol> 
			</li>
			<li>
				相对定位 position: relative;
				<ol>
					<li>不脱离标准布局</li>
					<li>它的位置还在</li>
				</ol>
			</li>
			<li>
				绝对定位 position: absolute;
				<ol>
					<li>绝对定位完全脱标,不占有位置</li>
					<li>如果自己有定位,父级一定要有定位</li>
					<li>用的最多的是 子绝父相</li>
				</ol>
			</li>
			<li>
				固定定位 position: fixed;
				<ol>
					<li>完全脱标,不占有位置,一般做固定位置</li>
				</ol>
			</li>
		</ol>
	</fieldset>
	<h1>定位Demo</h1>
	<dir class="backView">
		<img src="image/02.jpg">
		<a href="#" class="leftB"><img src="image/left.png"></a>
		<a href="#" class="rightB"><img src="image/right.png"></a>
		<ul class="circle">
			<li class="current"></li>
			<li></li>
			<li></li>
			<li></li>
			<li></li>
		</ul>
	</dir>
	

</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值