• js保持div悬浮,不随页面向下滚动而被覆盖


    <html>
    <head>
    <script type="text/javascript">
    //兼容性1,document.body.scrollTop 和 document.documentElement.scrollTop 兼容性2. style.top的值firefox需要加“px” , ie兼容此px ,无需另外加判断
    var stmnBASE = 840; //起始顶部间距(原始值)
    var stmnActivateSpeed = 1000; //
    var stmnScrollSpeed = 10; //
    var stmnTimer;

    function RefreshStaticMenu() {
    var top, stmnRefreshTimer;
    stmnRefreshTimer = stmnActivateSpeed;
    top = document.documentElement.scrollTop || (document.body ? document.body.scrollTop : 0);
    document.getElementById('STATICMENU').style.top = 1000 + "px";

    //挪动到新位置
    if (top > stmnBASE)
    document.getElementById('STATICMENU').style.top = top + "px";
    //恢复到原位置
    else
    document.getElementById('STATICMENU').style.top = stmnBASE + "px";

    stmnRefreshTimer = stmnScrollSpeed;
    stmnTimer = window.setTimeout( 'RefreshStaticMenu()', stmnRefreshTimer);
    }
    function InitializeStaticMenu() {

    var topvalue = document.documentElement.scrollTop || (document.body?document.body.scrollTop:0);
    var topFinalvalue = topvalue + stmnBASE;
    document.getElementById('STATICMENU').style.top = topFinalvalue + "px";
    RefreshStaticMenu();
    }
    </script>
    </head>
    <body>
    <div id="STATICMENU" class="right_nr news_right_nr" style="border-style:none;POSITION: absolute; TOP: 840px; ">
    <img alt="" src="/themes/Default/images/hotel/dl.png" />
    </div>
    <script type="text/javascript">InitializeStaticMenu();</script>
    </body>
    </html>



     

  • 相关阅读:
    WSL 修改默认登录用户为root
    WSL ssh服务自启动
    odoo 获取model的所有字段
    C++类型父类与子类的转换--dynamic_cast(转)
    开源软件/镜像库
    C/C++编译器gcc的windows版本MinGW-w64安装教程(转)
    msys2 环境搭建
    Windows下利用Cygwin搭建C/C++开发环境GCC(转)
    模板类中子类访问父类中的成员需要通过this指针
    C++ 构造函数与this指针
  • 原文地址:https://www.cnblogs.com/imust2008/p/2417954.html
Copyright © 2020-2023  润新知