zoukankan      html  css  js  c++  java
  • div在IE6中固定

    在IE6中固定一div在右下角,但是ie6不支持position:fixed属性,那么只能通过js实现,通过js判断浏览器在ie6的情况下,div的position为absoluate;right:0;bottom:0;indexOf() 方法对大小写敏感,如果要检索的字符串值没有出现,则该方法返回 -1。

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <meta name="author" content="智能社 - zhinengshe.com">
    <meta name="copyright" content="智能社 - zhinengshe.com">
    <title>智能社 - www.zhinengshe.com</title>
    <style>
    * { margin:0; padding:0; }
    body { height:1000px; }
    div { position:fixed; bottom:0; right:0; 100px; height:100px; background:red;
        _position:absolute; _bottom:auto;/*_position仅ie6识别*/
    }
    </style>
    
    <script>
    window.onresize=window.onload=window.onscroll=function (){
        if(window.navigator.userAgent.indexOf('MSIE 6.0') != -1)//判断ie6情况下
        {
            var oDiv=document.getElementById('div1');
            var nHeight=oDiv.offsetHeight;
            var scrollTop=document.documentElement.scrollTop || document.body.scrollTop;
            var a=document.documentElement.clientHeight-nHeight+scrollTop;//可视区的高度减去div盒子模型的高度加上滚动条的高度
            oDiv.style.top=a+'px';
        }
    };
    </script>
    </head>
    
    <body>
        <div id="div1"></div>
    </body>
    </html>
  • 相关阅读:
    PDB文件详解
    C++模板常用功能讲解
    Windows下多线程编程(二)
    关于静态库中使用全局变量可能导致的问题
    js中的函数
    js中字符串的加密base64
    列表推导式
    函数和方法的区别
    xshell连不上虚拟机
    网络编程,并行,并发和协程
  • 原文地址:https://www.cnblogs.com/heboliufengjie/p/4163059.html
Copyright © 2011-2022 走看看