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>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.