用position:fixed定位小图标位于版面一侧固定距离

效果:

<style>
	.f1{
		/*设置版面宽度为800*/
		 800px;
		height: 800px;
		background-color: skyblue;

		/*版面让左右自动实现居中*/
		margin:0 auto;

		  
	}
	.f2{
		 100px;
		height: 200px;
		background-color: yellow;
		/*第一步:设置定位为fixed*/
		position: fixed; 
		/*第二步:定位于左上0,再定位窗口正中心*/
		top:0;
		left: 50%;
		/*第三步:再偏移到中心左侧,版面中心的一半距离,即刚好到版面边上,这样定位不会因浏览器窗口大小而改变到版面的距离*/
		margin-left:400px;
		
	}
</style>
	<div class="f1"></div>
	<div class="f2"></div>

原文地址:https://www.cnblogs.com/chenxi188/p/13699395.html