• js 上下左右滚动代码


    <base href="http://image2.sina.com.cn/gm/lineage2/whz/newwh/images/fy/images/images/ifimage/">
    向上
    <div id=demo style="overflow:hidden; 128px; height:300px;">
    <div id=demo1>
    <img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br>

    </div>
    <div id=demo2></div>
    </div>
    <script language="javascript">
    var speed=30
    demo2.innerHTML=demo1.innerHTML
    function Marquee(){
    if(demo2.offsetTop-demo.scrollTop<=0)
    demo.scrollTop-=demo1.offsetHeight
    else{
    demo.scrollTop++
    }
    }
    var MyMar=setInterval(Marquee,speed)
    demo.onmouseover=function() {clearInterval(MyMar)}
    demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
    </script>

    向下

    <div id=demo3 style="overflow:hidden; 128px; height:300px;">
    <div id=demo4>
    <img src="gfjs.gif"><br><img src="bxtt.gif"><br><img src="bzjd.gif"><br>
    </div>
    <div id=demo5></div>
    </div>
    <script language="javascript">
    var speed=30
    demo5.innerHTML=demo4.innerHTML
    demo3.scrollTop=demo3.scrollHeight
    function Marquee(){
    if(demo3.scrollTop<=0)
    demo3.scrollTop+=demo5.offsetHeight
    else{
    demo3.scrollTop--
    }
    }
    var MyMar=setInterval(Marquee,speed)
    demo3.onmouseover=function() {clearInterval(MyMar)}
    demo3.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
    </script>

    向左

    <div id=demo6 style="overflow:hidden;height:100px;300px;"><table align=left

    cellpadding=0 cellspace=0 border=0><tr><td id=demo7 valign=top><img src="gfjs.gif"><img

    src="bxtt.gif"><img src="bzjd.gif"></td><td id=demo8 valign=top></td></tr></table></div>
    <script>
    var speed=30
    demo8.innerHTML=demo7.innerHTML
    function Marquee(){
    if(demo8.offsetWidth-demo6.scrollLeft<=0)
    demo6.scrollLeft-=demo7.offsetWidth
    else{
    demo6.scrollLeft++
    }
    }
    var MyMar=setInterval(Marquee,speed)
    demo6.onmouseover=function() {clearInterval(MyMar)}
    demo6.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
    </script>

    向右

    <div id=demo9 style="overflow:hidden;height:100px;300px;"><table align=left

    cellpadding=0 cellspace=0 border=0><tr><td id=demo10 valign=top><img src="gfjs.gif"><img

    src="bxtt.gif"><img src="bzjd.gif"></td><td id=demo11 valign=top></td></tr></table></div>
    <script>
    var speed=30
    demo11.innerHTML=demo10.innerHTML
    demo9.scrollLeft=demo9.scrollWidth
    function Marquee(){
    if(demo9.scrollLeft<=0)
    demo9.scrollLeft+=demo11.offsetWidth
    else{
    demo9.scrollLeft--
    }
    }
    var MyMar=setInterval(Marquee,speed)
    demo9.onmouseover=function() {clearInterval(MyMar)}
    demo9.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
    </script>

     

    在左右滚动的时候,不能把里面滚动区域的代码定义成div的而要用table,因为div定义左右位置时比较困难。这是我总结。 不知是否是这样。 我用了div 滚动总是有问题。

  • 相关阅读:
    go语言基础之安装go开发环境和beego
    mysql之事件的开启和调用
    系统和应用监控指标
    常用的17个运维监控系统(必备知识)
    Kafka Java API操作topic
    Linux安装mysql8.0
    mybatis+Oracle 批量插入数据,有数据做更新操作
    ORACLE数据库导出表,字段名,长度,类型,字段注释,表注释语句
    ORACLE 按时间创建分区表
    oracle创建表空间和用户
  • 原文地址:https://www.cnblogs.com/sunrise/p/1662289.html
Copyright © 2020-2023  润新知