zoukankan      html  css  js  c++  java
  • 可左右滚动的导航

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <meta name="keywords" content="站长,网页特效,js特效,广告代码,zzjs,zzjs.net,sky,www.zzjs.net,站长特效 网" />
    <meta name="description" content="www.zzjs.net,站长特效网,站长必备js特效及广告代码。大量高质量js特效,提供高质量广告代码下载,尽在站长特效网" />
    <title>可左右拖动的导航菜单,sky整理收集。</title>
    <style>
    ul{margin:0;padding:0;list-style:none;100000px}
    li{margin:0;padding:0;100px;height:100px;display:block;float:left;margin-right:5px;background:#009900}
    #img_bag{640px;height:100px;background:#FF9900;margin:0 auto;}
    #img_bag a{float:left;20px;display:block;height:20px;font-weight:bold;}
    #img_bag #img{600px;height:100px;background:#ccc;overflow:hidden;float:left}
    #scrollBar{600px;height:20px;background:#FF0000;margin:0 auto;position:relative}
    #scroll{30px;height:20px;background:#000;cursor:pointer;position:absolute;}
    </style>
    </head>
    <body>
    <a href="<#ZC_BLOG_HOST#>">站长特效网</a>,站长必备的高质量网页特效和广告代码。zzjs.net,站长js特效。<hr>
    <!--欢迎来到站长特效网,我们网站收集大量高质量js特效,提供许多广告代码下载,网址:www.zzjs.net,zzjs@msn.com,用.net打造靓站-->
    <div id="img_bag">
    <a href="javascript:void(0)" onmousedown="moveLeft()"><<</a>
    <div id="img">
    <ul>
    <li>站长特效网</li>
    <li>zzjs.net</li>
    <li>百度</li>
    <li>谷歌</li>
    <li>阿里西西</li>
    <li>蓝色理想</li>
    <li>中国站长站</li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    </ul>
    </div>
    <a href="javascript:void(0)" onmousedown="moveRight()">>></a>
    </div>
    <div style="clear:both;"></div>
    <div id="scrollBar">
    <div id="scroll" style="left:0"></div>
    </div>
    <script>
    function $(obj){return document.getElementById(obj)}
    var maxWidth=$("img").getElementsByTagName("ul")[0].getElementsByTagName("li").length*105;
    var isScroll=false;
    var modiLeft;
    $("scroll").onmousedown=function(evt){
    isScroll=true;
    evt=(evt)?evt:((window.event)?window.event:null);
    if(evt.offsetX){
    modiLeft=parseInt(evt.offsetX)
    }//欢迎来到站长特效网,我们的网址是www.zzjs.net,很好记,zz站长,js就是js特效,本站收集大量高质量js代码,还有许多广告代码下载。
    else{modiLeft=parseInt(evt.layerX)}
    }
    document.onmouseup=function(){
    isScroll=false;
    }
    document.onmousemove=function(evt){
    evt=(evt)?evt:((window.event)?window.event:null);
    if(evt&&isScroll){
    $("scroll").style.left=parseInt(evt.clientX)-parseInt($("scrollBar").offsetLeft)-modiLeft+"px";
    if(parseInt($("scroll").style.left)<0){$("scroll").style.left=0+"px"}
    if(parseInt($("scroll").style.left)>570){$("scroll").style.left=570+"px"}
    $("img").scrollLeft=parseInt($("scroll").style.left)*((maxWidth-600)/570);
    }
    }
    var targetx = 200;//一次滚动距离
    var dx;
    var a=null;
    function moveLeft(){
    var le=parseInt($("img").scrollLeft);
    if(le>200){
    targetx=parseInt($("img").scrollLeft)-200;
    }//欢迎来到站长特效网,我们的网址是www.zzjs.net,很好记,zz站长,js就是js特效,本站收集大量高质量js代码,还有许多广告代码下载。
    else{targetx=parseInt($("img").scrollLeft)-le-1}
    scLeft();
    }//欢迎来到站长特效网,我们的网址是www.zzjs.net,很好记,zz站长,js就是js特效,本站收集大量高质量js代码,还有许多广告代码下载。
    function scLeft(){
    dx=parseInt($("img").scrollLeft)-targetx;
    $("img").scrollLeft-=dx*.3;
    $("scroll").style.left=parseInt($("img").scrollLeft)*(570/(maxWidth-600))+"px";
    if(parseInt($("scroll").style.left)<0){$("scroll").style.left=0+"px"}
    if(parseInt($("scroll").style.left)>570){$("scroll").style.left=570+"px"}
    clearScroll=setTimeout(scLeft,50);
    if(dx*.3<1){clearTimeout(clearScroll)}
    }
    function moveRight(){
    var le=parseInt($("img").scrollLeft)+200;
    var maxL=maxWidth-600;
    if(le<maxL){
    targetx=parseInt($("img").scrollLeft)+200;
    }
    else{targetx=maxL}
    scRight();
    }
    function scRight(){
    dx=targetx-parseInt($("img").scrollLeft);
    $("img").scrollLeft+=dx*.3;
    $("scroll").style.left=parseInt($("img").scrollLeft)*(573/(maxWidth-600))+"px";
    if(parseInt($("scroll").style.left)<0){$("scroll").style.left=0+"px"}
    if(parseInt($("scroll").style.left)>=570){$("scroll").style.left=570+"px"}
    a=setTimeout(scRight,50);
    if(dx*.3<1){clearTimeout(a)}
    }
    </script>
    </body>
    </html>

  • 相关阅读:
    一、Javadoc文档标记
    0-写在java系列文章之前
    Tomcat全攻略
    linux使用普通账户时,无法登录,提示“-bash: fork: retry: Resource temporarily unavailable”
    在Linux下安装和使用MySQL
    linux下修改jdk环境变量的方法
    linux下卸载系统自带或者非自带的jdk
    linux中 /etc/profile的作用
    每天一个linux命令:tar命令-jia2
    如何使用蓝湖设计稿同时适配PC及移动端
  • 原文地址:https://www.cnblogs.com/skyay/p/3826187.html
Copyright © 2011-2022 走看看