Home  >  Article  >  Web Front-end  >  div css layout picture continuous scrolling js implementation code_javascript skills

div css layout picture continuous scrolling js implementation code_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:28:081096browse

html layout code

Copy code The code is as follows:





无标题文档







  • 图片占有位

  • 图片占有位

  • 图片占有位

  • 图片占有位

  • 图片占有位

  • 图片占有位

  • 图片占有位

  • 图片占有位

  • 图片占有位

  • 图片占有位

  • 图片占有位

  • 图片占有位

  • 图片占有位

  • 图片占有位

  • 图片占有位

  • 图片占有位

  • 图片占有位






    <script> <br>toleft("demo","demo1","demo2",30,"onedemo"); <br>//toright("demo0","demo11","demo22",20,"ti2"); <br></script>



    js核心代码
    复制代码 代码如下:

    //调用向左滚动
    //toleft("demo","demo1","demo2",30,"ti1")
    //调用向右滚动
    //toright("demo0","demo11","demo22",20,"ti2")

    function $(id)
    {
    return document.getElementById(id)
    }

    //向左滚动函数,demo包含demo1与demo2,speed是滚动速度,flag一个网页内有多个时设置为不同的任意字符。
    function toleft(demo,demo1,demo2,speed,flag)
    {
    demo=$(demo);
    demo1=$(demo1);
    demo2=$(demo2)
    demo2.innerHTML=demo1.innerHTML
    function Marquee()
    {
    if(demo2.offsetWidth-demo.scrollLeft<=0)
    {
    demo.scrollLeft-=demo1.offsetWidth
    }
    else
    {
    demo.scrollLeft
    }
    }
    flag=setInterval(Marquee,speed)
    demo.onmouseover=function()
    {
    clearInterval(flag);
    }
    demo.onmouseout=function()
    {
    flag=setInterval(Marquee,speed);
    }
    }


    //向右滚动函数,demo包含demo1与demo2,speed是滚动速度,flag一个网页内有多个时设置为不同的任意字符。
    function toright(demo,demo1,demo2,speed,flag)
    {
    demo=$(demo);
    demo1=$(demo1);
    demo2=$(demo2)
    demo2.innerHTML=demo1.innerHTML
    function Marquee()
    {
    if(demo.scrollLeft<=0)
    {
    demo.scrollLeft=demo2.offsetWidth
    }
    else
    {
    demo.scrollLeft--
    }
    }
    flag=setInterval(Marquee,speed)
    demo.onmouseover=function()
    {
    clearInterval(flag);
    }
    demo.onmouseout=function()
    {
    flag=setInterval(Marquee,speed);
    }
    }

    If you need more functions, you can refer to the following content:
    JavaScript four-direction picture scrolling effect
    JavaScript seamless up, down, left, and right scrolling plus fixed height and fixed width pause effect (compatible with ie/ff)
    Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn