css IE6 position:fixed (固定定位)通過position:absolute的解決方案

來源:互聯網
上載者:User

css教程 ie6 position:fixed (固定定位)通過position:absolute的解決方案,完全使用position:absolute來解決固定定位問題。因為其他的瀏覽器都支援絕對位置,在ie6,7,8,9,ff,chrome中均測試通過。注意一點:不能給外包含的元素mod-test設定高度,不然的話,是沒有捲軸的。而應該在裡面設定一個容器,它設定一個高度

 <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
 5 <title>ie6 position:fixed bug</title>
 6 <style type="text/css">
 7 body { height:100%; overflow:hidden;  position:relative;}
 8 html { height:100%; overflow:hidden;}
 9 .test{position:absolute;top:100px;left:100px;padding:2px;border:1px solid #aaa;}
10 .mod-test{
11 height:100%;
12 overflow:auto;   
13 }
14 .inlet{
15 height:1800px;
16 }
17 </style>
18 </head>
19 <body>
20 <div class="mod-test">
21 <div class="inlet">
22   <h1>
23   <a href="" title="ie6 position:fixed bug" rel="bookmark">ie6 position:fixed bug</a>
24   </h2>
25    <div class="test">
26    <img src="dj.jpg"/><br/>我一直在的
27    </div>
28    </div>
29 </div>
30 </body>

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.