CSS定位

文章详细介绍了HTML中的绝对定位、相对定位以及CSS中的固定定位和粘性定位概念,通过示例展示了如何在网页布局中运用这些定位方式。同时,还探讨了教师的角色,强调了他们对学生成长的重要性。
摘要由CSDN通过智能技术生成

绝对定位

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			.father{
				/* 相对父亲类进行定位 */
				position: relative;
				width: 900px;
				height: 400px;
				background-color: aqua;
			}
			.son1{
				background-color: pink;
				/* 相对定位 */
				position: absolute;
				/* 距离顶部200px */
				top: 150px;
				/* 距离右边0px */
				right: 0px;
				/* 设置层级优先级 */
				z-index: 1;
			}
			.son2{
				background-color: blue;
				/* 相对定位 */
				position: absolute;
				/* 距离顶部200px */
				top: 150px;
				/* 距离右边0px */
				left: 0px;
			}
			.son{
				width: 100px;
				height: 100px;
			}
			div{
				color: red;
				text-align: center;
				line-height: 100px;
			}
		</style>
	</head>
	<body>
		<div class="father">
			我是father
			<div class="son son1">我是son1</div>
			<div class="son son2">我是son2</div>
		</div>
	</body>
</html>

固定定位

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			body{
				height: 3000px;
				background-color: aqua;
			}
			div{
				position: fixed;
				bottom: 15px;
				right: 10px;
				width: 300px;
				height: 300px;
				background-color: pink;
			}
		</style>
	</head>
	<body>
		<div>我永远固定在右下角</div>
	</body>
</html>

粘性定位

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>
			.pos1{
				background-color: aqua;
				/* 设置为粘性定位 */
				position: sticky;
				top: 20px;
			}
		</style>
	</head>
	<body>
		<p> My teacher, Miss Wang, helped me a lot in 
		my middle school life. She is a kind easygoing 
		woman. I must thank her for making a confident 
		girl.  I used to be a shy and unconfident girl. 
		Mrs. Wang noticed me. She took good care of me and
		 encouraged me to join the school speech contest. 
		 Of course, I failed. But Mrs. Wang cheered me up a
		 nd said every man is the architect of his o
		 wn future.  From then on, I practiced every day
		 . It goes without saying “No pain, no gain.” I w
		 on the contest in the second term. In my opinion
		 <p class="pos1">我就是粘性定位</p>
		 , teachers are the same as gardeners and they volu
		 nteer today and gain tomorrow. Not only can they
		  teach knowledge but also they can teach student
		  s how to be a successful man.  Thank you, Mrs
		  . Wang. You make a duck become a beautiful swa
		  n. I want to be a teacher that as same as you in
		   the future.My teacher, Miss Wang, helped me a 
		   lot in my middle school life. She is a kind e
		   asygoing woman. I must thank her for making a c
		   onfident girl.  I used to be a shy and unconfiden
		   t girl. Mrs. Wang noticed me. She took good care o
		   f me and encouraged me to join the school speec
		   h contest. Of course, I failed. But Mrs. Wang c
		   heered me up and said every man is the archite
		   ct of his own future.  From then on, I practic
		   ed every day. It goes without saying “No pain,
			no gain.” I won the contest in the second t
			erm. In my opinion, teachers are the same as g
			ardeners and they volunteer today and gain tom
			orrow. Not only can they teach knowledge but
			 also they can teach students how to be a 
			 successful man.  Thank you, Mrs. Wang. 
			 You make a duck become a beautiful swan. 
			 I want to be a teacher that as same as you in
			  the future.My teacher, Miss Wang, helped me a
			   lot in my middle school life. She is a kind
				easygoing woman. I must thank her for makin
				g a confident girl.  I used to be a shy and 
				unconfident girl. Mrs. Wang noticed me. She t
				ook good care of me and encouraged me to join t
				he school speech contest. Of course, I failed.
				 But Mrs. Wang cheered me up and said every m
				 an is the architect of his own future.  F
				 rom then on, I practiced every day. It goes
				  without saying “No pain, no gain.” I wo
				  n the contest in the second term. In my opin
				  ion, teachers are the same as gardeners and th
				  ey volunteer today and gain tomorrow. Not
				   only can they teach knowledge bu
				   t also they can teach students how
					to be a successful man.  Thank y
					ou, Mrs. Wang. You make a duck become
					 a beautiful swan. I want to be a tea
					 cher that as same as you in the future
					 .My teacher, Miss Wang, helped me a lot in m
					 y middle school life. She is a kind e
					 asygoing woman. I must thank her for
					  making a confident girl.  I used to
					   be a shy and unconfident girl. Mrs
					   . Wang noticed me. She took good care of m
					   e and encouraged me to join the school speech contest. Of course, I failed. But Mrs. Wang cheered me up and said every man is the architect of his own future.  From then on, I practiced every day. It goes without saying “No pain, no gain.” I won the contest in the second term. In my opinion, teachers are the same as gardeners and they volunteer today and gain tomorrow. Not only can they teach knowledge but also they can teach students how to be a successful man.  Thank you, Mrs. Wang. You make a duck become a beautiful swan. I want to be a teacher that as same as you in the future.My teacher, Miss Wang, helped me a lot in my middle school life. She is a kind easygoing woman. I must thank her for making a confident girl.  I used to be a shy and unconfident girl. Mrs. Wang noticed me. She took good care of me and encouraged me to join the school speech contest. Of course, I failed. But Mrs. Wang cheered me up and said every man is the architect of his own future.  From then on, I practiced every day. It goes without saying “No pain, no gain.” I won the contest in the second term. In my opinion, teachers are the same as gardeners and they volunteer today and gain tomorrow. Not only can they teach knowledge but also they can teach students how to be a successful man.  Thank you, Mrs. Wang. You make a duck become a beautiful swan. I want to be a teacher that as same as you in the future.My teacher, Miss Wang, helped me a lot in my middle school life. She is a kind easygoing woman. I must thank her for making a confident girl.  I used to be a shy and unconfident girl. Mrs. Wang noticed me. She took good care of me and encouraged me to join the school speech contest. Of course, I failed. But Mrs. Wang cheered me up and said every man is the architect of his own future.  From then on, I practiced every day. It goes without saying “No pain, no gain.” I won the contest in the second term. In my opinion, teachers are the same as gardeners and they volunteer today and gain tomorrow. Not only can they teach knowledge but also they can teach students how to be a successful man.  Thank you, Mrs. Wang. You make a duck become a beautiful swan. I want to be a teacher that as same as you in the future.My teacher, Miss Wang, helped me a lot in my middle school life. She is a kind easygoing woman. I must thank her for making a confident girl.  I used to be a shy and unconfident girl. Mrs. Wang noticed me. She took good care of me and encouraged me to join the school speech contest. Of course, I failed. But Mrs. Wang cheered me up and said every man is the architect of his own future.  From then on, I practiced every day. It goes without saying “No pain, no gain.” I won the contest in the second term. In my opinion, teachers are the same as gardeners and they volunteer today and gain tomorrow. Not only can they teach knowledge but also they can teach students how to be a successful man.  Thank you, Mrs. Wang. You make a duck become a beautiful swan. I want to be a teacher that as same as you in the future. </p>
					   <p>, teachers are the same as gardeners and they volu
		 nteer today and gain tomorrow. Not only can they
		  teach knowledge but also they can teach student
		  s how to be a successful man.  Thank you, Mrs
		  . Wang. You make a duck become a beautiful swa
		  n. I want to be a teacher that as same as you in
		   the future.My teacher, Miss Wang, helped me a 
		   lot in my middle school life. She is a kind e
		   asygoing woman. I must thank her for making a c
		   onfident girl.  I used to be a shy and unconfiden
		   t girl. Mrs. Wang noticed me. She took good care o
		   f me and encouraged me to join the school speec
		   h contest. Of course, I failed. But Mrs. Wang c
		   heered me up and said every man is the archite
		   ct of his own future.  From then on, I practic
		   ed every day. It goes without saying “No pain,
			no gain.” I won the contest in the second t
			erm. In my opinion, teachers are the same as g
			ardeners and they volunteer today and gain tom
			orrow. Not only can they teach knowledge but
			 also they can teach students how to be a 
			 successful man.  Thank you, Mrs. Wang. 
			 You make a duck become a beautiful swan. 
			 I want to be a teacher that as same as you in
			  the future.My teacher, Miss Wang, helped me a
			   lot in my middle school life. She is a kind
				easygoing woman. I must thank her for makin
				g a confident girl.  I used to be a shy and 
				unconfident girl. Mrs. Wang noticed me. She t
				ook good care of me and encouraged me to join t
				he school speech contest. Of course, I failed.
				 But Mrs. Wang cheered me up and said every m
				 an is the architect of his own future.  F
				 rom then on, I practiced every day. It goes
				  without saying “No pain, no gain.” I wo
				  n the contest in the second term. In my opin
				  ion, teachers are the same as gardeners and th
				  ey volunteer today and gain tomorrow. Not
				   only can they teach knowledge bu
				   t also they can teach students how
					to be a successful man.  Thank y
					ou, Mrs. Wang. You make a duck become
					 a beautiful swan. I want to be a tea
					 cher that as same as you in the future
					 .My teacher, Miss Wang, helped me a lot in m
					 y middle school life. She is a kind e
					 asygoing woman. I must thank her for
					  making a confident girl.  I used to
					   be a shy and unconfident girl. Mrs
					   . Wang noticed me. She took good</p>
	</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

麦农111

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

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

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

打赏作者

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

抵扣说明:

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

余额充值