相容ie6、ie7、ff的css頂端固定位置定位

來源:互聯網
上載者:User

body{<br /> background-image:url(about:blank);<br /> background-attachment:fixed;<br />}<br />.myDiv{<br /> position:fixed !important;<br /> position:absolute;<br /> top:expression(eval(document.documentElement.scrollTop));<br />}<br />

body元素中background-image:url(about:blank);background-attachment:fixed;可防止ie6中出現閃動;

因為ie6不支援position:fixed屬性,所以要設定它的優先順序高於position:absolute;

通過運算式動態調整top屬性為到捲軸上方長度

相關文章

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.