zoukankan      html  css  js  c++  java
  • 筋斗云导航

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
        <style>
    *{margin: 0; padding: 0;}
    ul {list-style:none;}
    body {
    background-color: #000;
    }
    .nav {
    800px;
    height: 42px;
    background:url("rss.png") no-repeat right center #fff;
    margin: 100px auto;
    border-radius: 5px;
    position: relative;
    }
    .cloud {
    83px;
    height: 42px;
    position: absolute;
    top: 0;
    left: 0;
    background: url(cloud.gif) no-repeat;
    }
    .nav ul {
    position: absolute;
    top: 0;
    left: 0;
    }
    .nav li {
    float: left;
    88px;
    height: 42px;
    line-height: 42px;
    text-align: center;
    color: #000;
    cursor: pointer;
    }
    </style>
    </head>
    <body>
    <div class="nav" id="nav">
    <span class="cloud" id="cloud"></span>
    <ul id="box">
    <li>首页新闻</li>
    <li>千锋师资</li>
    <li>千锋活动策划</li>
    <li>企业文化</li>
    <li>招聘信息</li>
    <li>公司简介</li>
    <li>上海校区</li>
    <li>广州校区</li>
    </ul>
    </div>
    </body>
    </html>
        <script type="text/javascript">
            var cloud = document.getElementById("cloud");
            var list = document.getElementsByTagName("li");
            var current = 0; //记录当前点击的位置
            var timer = null;
            
            function starMove( obj,target ){
                clearInterval( obj.timer );
                obj.timer = setInterval( function(){
                    var speed = ( target - obj.offsetLeft )/10;
                    speed = speed > 0 ? Math.ceil(speed) : Math.floor(speed);
                    if( obj.offsetLeft == target ){
                        clearInterval( obj,timer );
                    }else{
                        obj.style.left = obj.offsetLeft + speed + "px";
                    }
                },30 )  
            }
            
            for( var i = 0 ; i < list.length ; i++ ){
                list[i].onmouseenter = function(){
                    starMove( cloud, this.offsetLeft );
                }
                list[i].onmouseleave = function(){
                    starMove( cloud, current );
                }
                list[i].onclick = function(){
                    current = this.offsetLeft;
                }       
            }
        </script>
  • 相关阅读:
    [Web 前端] CSS 盒子模型,绝对定位和相对定位
    [Android Pro] 跨平台反编译工具 jadx (ubuntu亲测 可用)
    [Web 前端] Jquery 复制元素,并修改属性, 追加到另一个元素后面
    [Web 前端 ] Jquery attr()方法 获取或修改 对象的属性值
    [Web 前端] Jquery实现可直接编辑的表格
    [Web 前端] td长度固定,内容过长,超过部分用省略号代替
    [Network] okhttp3与旧版本okhttp的区别分析
    [Android Pro] AndroidStudio IDE界面插件开发(进阶篇之Editor)
    graph embedding 使用方法
    win10 'make' 不是内部或外部命令
  • 原文地址:https://www.cnblogs.com/tis100204/p/10328775.html
Copyright © 2011-2022 走看看