zoukankan      html  css  js  c++  java
  • 解决 IE6 position:fixed 固定定位问题!

    
    

      

    元素固定在浏览器的底部和距离右边的20个像素,这次的代码是:
    
    #top{
    position:fixed; 
    _position:absolute;
    bottom:0;
    right:20px;
    _bottom:auto;
    _top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));
    }
    
    right 跟 left 属性可以用绝对定位的办法解决,而 top 跟 bottom 就需要用上面的表达式来实现。其中在
    _position:absolute;
    中的
    _
    符号只有 IE6 才能识别,目的是为了区分其他浏览器。
    上面的只是一个例子,下面的才是最重要的代码片段:
    使元素固定在浏览器的顶部:
    
    使元素固定在浏览器的顶部:
    
    #top{
    _position:absolute;
    _bottom:auto;
    _top:expression(eval(document.documentElement.scrollTop));
    }
    
    使元素固定在浏览器的底部:
    
    #top{
    _position:absolute;
    _bottom:auto;
    _top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0)));
    }
    

      

  • 相关阅读:
    Python学习 :面向对象 -- 三大特性
    Python学习 :面向对象(一)
    小米oj #40 找小“3”
    第三次作业
    排序算法模板
    树状数组求逆序数
    最短路模板
    字典树模板
    LCS
    多项式朴素乘法
  • 原文地址:https://www.cnblogs.com/jonhson/p/2216473.html
Copyright © 2011-2022 走看看