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>

  • 相关阅读:
    telnet退出
    Eclipse srever起来时,时间超过45s。
    maven报错 Failure to transfer org.apache.maven.plugins:maven-compiler-plugin:pom:3.5.0 from
    需求讨论
    PyTorch学习笔记之计算图
    PyTorch学习笔记之CBOW模型实践
    PyTorch学习笔记之n-gram模型实现
    PyTorch学习笔记之初识word_embedding
    7月3日-9日_周报
    python学习笔记之heapq内置模块
  • 原文地址:https://www.cnblogs.com/sunhw360/p/4139800.html
Copyright © 2011-2022 走看看