在ie6下实现position-fixed的效果
这个只是模拟position-fixe,很不错的,兼容了现在的主流浏览器(IE6、IE7、IE8、火狐、Opera、谷歌浏览器)也就是说你现在用到得浏览器都会兼容的,
效果也不错,其实也很简单。
原理很简单:就是利用到了verflow:hidden;overflow:auto;position:relative; position:absolute;的应用,
要注意:html{ overflow:hidden; height:100%}也的加上,不然的话不会出现下拉条。
有了这个,你也可以用他来做对联广告了,省去JS,但是没有JS的效果,毕竟是css啊,哈哈
CSS:
1 <style type="text/css">
2 *{ margin:0; padding:0}
3 html{ overflow:hidden; height:100%}
4 body{ font-size:12px; overflow:hidden; position:relative; height:100%}
5 .fix{ position:absolute; width:120px; height:200px; border:1px solid #09F; background:#CCC; top:10px; left:10px}
6 .rolling{ overflow:auto; height:100%}
7 .rolling-cen{ margin:0 0 0 150px;}
8 </style>
9
2 *{ margin:0; padding:0}
3 html{ overflow:hidden; height:100%}
4 body{ font-size:12px; overflow:hidden; position:relative; height:100%}
5 .fix{ position:absolute; width:120px; height:200px; border:1px solid #09F; background:#CCC; top:10px; left:10px}
6 .rolling{ overflow:auto; height:100%}
7 .rolling-cen{ margin:0 0 0 150px;}
8 </style>
9
html:
1 <div class="fix">12312313213213</div>
2 <div class="rolling">
3 <div class="rolling-cen">
4 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br /><br /><br /><br />
5 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br /><br /><br /><br />
6 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br /><br /><br /><br />
7 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br /><br /><br /><br />
8 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br /><br /><br /><br />
9 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br /><br /><br /><br />
10 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br /><br /><br /><br />
11 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />
12 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />
13 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />
14 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />
15 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />
16 </div>
17 </div>
18
2 <div class="rolling">
3 <div class="rolling-cen">
4 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br /><br /><br /><br />
5 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br /><br /><br /><br />
6 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br /><br /><br /><br />
7 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br /><br /><br /><br />
8 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br /><br /><br /><br />
9 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br /><br /><br /><br />
10 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br /><br /><br /><br />
11 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />
12 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />
13 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />
14 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />
15 12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />12312313213213<br />
16 </div>
17 </div>
18