一 什么是固定定位
选择器 {position: fixed;}
案例:
二 贴合版心的固定定位
<style>
.w {
width:800px ;
height: 2000px;
background: pink;
margin: 0 auto;
}
.fixed {
position: fixed;
/* 1走浏览器宽度的一半 */
left: 50%;
/* 2 再走版心盒子的一半 */
margin-left: 400px;
width:50px ;
height: 150px;
background: skyblue;
}
</style>
</head>
<body>
<div class="fixed"></div>
<div class="w">版心盒子800px</div>
总结