当前位置:首页 > 代码 > 正文

js图片循环滚动代码(js图片循环滚动代码大全)

admin 发布:2022-12-19 06:14 132


今天给各位分享js图片循环滚动代码的知识,其中也会对js图片循环滚动代码大全进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

JS图片滚动怎么让鼠标经过后停止啊?

我写的代码,要下班了,所以就简单注释一下。鼠标经过会停止,移开鼠标会继续走。已经测试过了。另存xx.htm打开可看效果。

1234567891011121314151617181920212223242526272829303132script type="text/javascript"var timer_movex;start_timer(); function start_timer(){ timer_movex = setInterval(function() {//setInterval是js循环定时器每隔一段时间就执行一次function代码 var x = document.getElementById('x');//获得id为x的html元素 if(x.offsetLeft = 800) x.style.left = 0;//如果移动到了800的位置,则跳回左边0点重新开始移动 else x.style.left = x.offsetLeft + 50;//向右移动20个像素}, 1000);//每隔1000毫秒移动一次} function stop_timer() { clearInterval(timer_movex);} function movex(v) { var x = document.getElementById('x');//获得id为x的html元素 x.style.left = x.offsetLeft + v;//移动v个像素,v为正数则向右,负数则向左。x.style.left即为左边框位置。}/scriptdiv id="x" style="position:absolute; left:500px; top:100px; width:100px; height:100px; border=1px solid #000;" onmouseover="stop_timer()" onmouseout="start_timer()"h1TEST/h1/divforminput id="test" onclick="movex(-100)" value="点击左移" type="button"/input id="test" onclick="movex(100)" value="点击右移" type="button"/input id="test" onclick="start_timer()" value="start" type="button"/input id="test" onclick="stop_timer()" value="stop" type="button"//form

js高手进,如何能让鼠标停在图片上的时候停止滚动

#box1 div:hover{

animation-play-state: paused;

}

animation--play-state属性指定动画是否正在运行或已暂停。

语法: animation-play-state: paused|running;

paused 指定暂停动画

running 指定正在运行的动画

js实现图片左右滚动

代码:

    title/title

    style

        body{

            margin:0;

            padding:0;

            background-color:transparent;

        }

        div{

            width:350px;

            overflow:hidden;

        }

        table img{

            width:100px;

            height:100px;

        }

    /style

/head

body

    div id="picScroll"

        table

            tr

                tdaimg src="../pic/1.jpg" //a/td

                tdaimg src="../pic/2.jpg"/a/td

                tdaimg src="../pic/3.jpg"/a/td

                tdaimg src="../pic/4.jpg"/a/td

                tdaimg src="../pic/5.jpg"/a/td

            /tr

        /table

    /div

/body

/html

script

    var target = $('#picScroll');

    var left = 0;

    var speed = 30;

    function Marqeen() {

        if (target[0].offsetWidth = left) {

            left -= target[0].offsetWidth;

        }

        else {

            left++;

        }

        target.scrollLeft(left);

    }

    $(function () {

        var marQueen = window.setInterval(Marqeen, speed);

        target.mouseover(function () {

            clearInterval(marQueen);

        });

        target.mouseout(function () {

            marQueen = window.setInterval(Marqeen, speed);

        });

    });

/script

关于js图片循环滚动代码和js图片循环滚动代码大全的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/3656.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载