IE6中position:fixed無效問題解決

來源:互聯網
上載者:User

在做頁面右下腳對話方塊時,直接使用position:fixed;大部分瀏覽器很容易就能做到,但是在IE6中卻發現不行,原來是IE6不支援position:fixed;這個屬性。

雖然用JS肯定能解決這個問題,但是總覺得用JS來做布局的工作不是很好,網上找了下這個問題,發現可以直接用CSS方法解決,代碼如下:

 代碼如下 複製代碼

_position:absolute;

_bottom:auto;

_top:expression(eval(document.compatMode && document.compatMode=='CSS1Compat') ? documentElement.scrollTop +(documentElement.clientHeight-this.clientHeight) - 1 : document.body.scrollTop +(document.body.clientHeight-this.clientHeight) - 1);

 

其實上面方法也是通過JS來定位解決,只不過是將JS代碼寫在CSS中了

jquery固定層頂部固定層和底部固定層不抖動並且支援IE6

HTML代碼:

 代碼如下 複製代碼

<div class="shortcut">
 <h1><a href="http://www.111cn.net/">jquery固定層頂部固定層和底部固定層不抖動並且支援IE6</a></h1>
 <span class="right">
  <a href="http://www.111cn.net">下載特效</a>
 </span>
</div>

<div class="bottomcut">
 <h1><a href="http://www.111cn.net/">jquery固定層頂部固定層和底部固定層不抖動並且支援IE6</a></h1>
 <span class="right">
  <a href="http://www.111cn.net/">下載特效</a>
 </span>
</div>

JS代碼:

 代碼如下 複製代碼

<script type="text/javascript">
$(document).ready(function(){

 $(window).scroll(function(){
  if($.browser.msie && $.browser.version=="6.0")$(".bottomcut").css("top",$(window).height()-$(".bottomcut").height()+$(document).scrollTop());
 });
 
});
</script>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.