zoukankan      html  css  js  c++  java
  • 浮动广告

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>随鼠标滚动的广告图片</title>
    <style type="text/css">
    #main{text-align:center;}
    #adver{
    position:absolute;
    left:50px;
    top:30px;
    z-index:2;
    }
    </style>
    <script type="text/javascript">
    var adverTop; //层距页面顶端距离
    var adverLeft;
    var adverObject; //层对象
    function inix(){
    adverObject=document.getElementById("adver"); //获得层对象
    if(adverObject.currentStyle){
    adverTop=parseInt(adverObject.currentStyle.top);//获取层对象距离页面顶端的距离
    adverLeft=parseInt(adverObject.currentStyle.left);
    }
    else{
    adverTop=parseInt(document.defaultView.getComputedStyle(adverObject,null).top);
    adverLeft=parseInt(document.defaultView.getComputedStyle(adverObject,null).left);
    }
    }
    function move(){
    adverObject.style.top=adverTop+parseInt(document.documentElement.scrollTop)+"px";获取鼠标滚动的距离
    adverObject.style.left=adverLeft+parseInt(document.documentElement.scrollLeft)+"px";
    }
    window.onload=inix;
    window.onscroll=move;
    </script>
    </head>
    <body>
    <div id="adver"><img src="images/adv.jpg"/></div>
    <div id="main"><img src="images/main1.jpg"/><img src="images/main2.jpg"/><img src="images/main3.jpg"/></div>
    </body>
    </html>

  • 相关阅读:
    [Ljava.lang.String; cannot be cast to java.lang.String 报错的原因
    ajaxfileupload多文件上传
    如何设置 html 中 select 标签不可编辑、只读
    docker
    nvm use 指定版本后无效 win7
    win7禁用Adnimistrator账号登录
    win10安装tomcat9
    webstorm命令行无法使用node-gyp进行编译
    tomcat7.0安装笔记
    win10 java1.7安装笔记
  • 原文地址:https://www.cnblogs.com/tian114527375/p/4928653.html
Copyright © 2011-2022 走看看