zoukankan      html  css  js  c++  java
  • IE6不支持fixed

    #goto-top {
    		display:none;
    		position:fixed;
    		38px;
    		height:36px;
    		background:url(../images/goto-top.png) no-repeat 0 0;
    		bottom:40px;
    		right:40px;
    		-webkit-transition:all 0.2s;
    		-moz-transition:all 0.2s;
    		-o-transition:all 0.2s;
    		transition:all 0.2s;
    		z-index:9999;
    	}
    /*ie6*/
    * html body {background-image:url(about:blank);background-attachment:fixed}    /*解决IE6闪动*/
    * html #goto-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))); 
        _margin-bottom: 40px;    /*定位底部*/
    	}
    

    注释: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)));}

    这两段代码只能实现在最底部跟最顶部,你可以使用 _margin-top:10px; 或者 _margin-bottom:10px;修改其中的数值控制元素的位置。

    position:fixed; 闪动问题

    现在,问题还没有完全解决。在用了上面的办法后,你会发现:被固定定位的元素在滚动滚动条的时候会闪动。解决闪动问题的办法是在 CSS 文件中加入:

    *html{
        background-image:url(about:blank);
        background-attachment:fixed;}

    其中 * 是给 IE6 识别的。

  • 相关阅读:
    98.公共汽车
    100.选菜(动态规划)01背包
    102.愤怒的LJF
    96.老鼠的旅行(动态规划)
    95.(01背包)之小吃
    94.Txx考试
    93.数字三角形W(深搜)
    POJ 3352 Road Construction (边双连通分量)
    POJ 3114 Countries in War(强联通分量+Tarjan)
    POJ 3592 Instantaneous Transference(强联通分量 Tarjan)
  • 原文地址:https://www.cnblogs.com/gzya/p/5535021.html
Copyright © 2011-2022 走看看