固定定位,就是相对浏览器窗口定位。页面如何滚动,这个盒子显示的位置不变。
固定定位脱标!
IE6不兼容 固定定位!!!
代码如下:
<title>固定定位</title>
<style>
*{
margin: 0;
padding: 0;
}
.top{
width: 100%;
height: 45px;
background-color: #333;
/* 固定定位 */
position: fixed;
left: 0;
top: 0;
}
.container{
width: 1200px;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="top"></div>
<div class="container">
<img src="./image/nanxun1.png" alt="">
<img src="./image/nanx2.png" alt="">
</div>
预览: