zoukankan      html  css  js  c++  java
  • javascript-压顶广告效果

    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Top AD</title>
    <style type="text/css">
    body{margin: 0 auto;padding: 0;}
    a:focus{outline: none;}
    #ad{background: #e8e8e8; 960px; display: none;margin: 0 auto;text-align: center;overflow:hidden;position:relative;}
    .slide{ 960px;margin: 0 auto;background: gray;text-align: center;height: 40px;line-height: 40px;color: #fff;}
    #colse{30px;height:30px;background-color:#666;color:#fff;position:absolute;top:0;right:0;font-size: 12px;line-height: 30px;}
    </style>
    </head>
    <body>
        <div id="ad">
            <h1>欢迎来到风行网</h1>
            <h2>大幅广告</h2>
            <span id="colse">关闭</span>
        </div>
        <p class="slide">风行网欢迎你</p>
    </body>
    <script type="text/javascript">
    var tim = 0, time = 0, timer = 0, ttl = 30, tt = 5000;
    var h = 0, maxH = 200;

    function addH(){
        var ele = document.getElementById('ad');
        if(h < maxH){
            ele.style.display = 'block';
            h = h + 5;
            ele.style.height = h + 'px'; 
        }else{
            return;
        }
        clearTimeout(time);
        time = setTimeout(addH, ttl);
    }
    function decH(){
        var ele = document.getElementById('ad');
        if(h > 0){
            h = h - 5;
            ele.style.height = h + 'px';
        }else{
            ele.style.display = 'none';
        }
        clearTimeout(tim);
        tim = setTimeout(decH, ttl);   
    }
    function colseFun(){
        clearTimeout(time);
        clearTimeout(timer);
        decH();
    }

    window.onload = function(){
        addH();
        var colseBtn = document.getElementById('colse');
        colseBtn.onclick = colseFun;
        clearTimeout(timer);
        timer = setTimeout(decH, tt);
    }
    </script>
    </html>

  • 相关阅读:
    Python内置的操作系统模块(os)与解释器交互模块(sys)
    Python常用模块-常见的加密算法模块使用
    Python常用模块-随机数模块(random)
    Python常用模块-时间模块(time&datetime)
    Python递归函数介绍
    Python内置函数之匿名(lambda)函数
    Python远程连接模块-Telnet
    Python的常用内置函数介绍
    Python的生成器进阶玩法
    Python中的列表解析和生成器表达式
  • 原文地址:https://www.cnblogs.com/sunhw360/p/4139800.html
Copyright © 2011-2022 走看看