無縫滾動

<!DOCTYPE html>

<html lang="en">

<head>

? ? <meta charset="UTF-8">

? ? <title>無縫滾動</title>

? ? <style type="text/css">

? ? ? ? body,ul,li{margin:0;padding:0}

? ? ? ? ul{list-style:none;}

? ? ? ? .slide{

? ? ? ? ? ? width:500px;

? ? ? ? ? ? height:100px;

? ? ? ? ? ? border:1px solid #ddd;

? ? ? ? ? ? margin:20px auto 0;

? ? ? ? ? ? position:relative;

? ? ? ? ? ? overflow:hidden;

? ? ? ? }

? ? ? ? .slide ul{

? ? ? ? ? ? position:absolute;

? ? ? ? ? ? width:1000px;

? ? ? ? ? ? height:100px;

? ? ? ? ? ? left:0;

? ? ? ? ? ? top:0;

? ? ? ? }

? ? ? ? .slide ul li{

? ? ? ? ? ? width:90px;

? ? ? ? ? ? height:90px;

? ? ? ? ? ? margin:5px;

? ? ? ? ? ? background-color:#ccc;

? ? ? ? ? ? line-height:90px;

? ? ? ? ? ? text-align: center;

? ? ? ? ? ? font-size:30px;

? ? ? ? ? ? float:left;

? ? ? ? }

? ? ? ? .btns{

? ? ? ? ? ? width:500px;

? ? ? ? ? ? height:50px;

? ? ? ? ? ? margin:10px auto 0;

? ? ? ? }

? ? </style>

? ? <script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>

? ? <script type="text/javascript">

? ? ? ? $(function(){


? ? ? ? ? ? var $ul = $('#slide ul');

? ? ? ? ? ? var left = 0;

? ? ? ? ? ? var deraction = 2;

? ? ? ? ? ? $ul.html($ul.html()+$ul.html());

? ? ? ? ? ? var timer = setInterval(move,30);

? ? ? ? ? ? function move(){

? ? ? ? ? ? ? ? left-=deraction;

? ? ? ? ? ? ? ? if(left<-500){


? ? ? ? ? ? ? ? ? ? left = 0;

? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? if(left>0){

? ? ? ? ? ? ? ? ? ? left=-500;

? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? $ul.css({left:left});

? ? ? ? ? ? }

? ? ? ? ? ? $('#btn1').click(function(){

? ? ? ? ? ? ? ? deraction = 2;

? ? ? ? ? ? });

? ? ? ? ? ? $('#btn2').click(function(){

? ? ? ? ? ? ? ? deraction = -2;

? ? ? ? ? ? })

? ? ? ? ? ? $('#slide').mouseover(function(){

? ? ? ? ? ? ? ? clearInterval(timer);? ? ? ? ? ? ?

? ? ? ? ? ? })

? ? ? ? ? ? $('#slide').mouseout(function(){

? ? ? ? ? ? ? ? timer = setInterval(move,30);? ? ? ? ?

? ? ? ? ? ? })

? ? ? ? })

? ? </script>

</head>

<body>

? ? <div class="btns">

? ? ? ? <input type="button" name="" value="向左" id="btn1">

? ? ? ? <input type="button" name="" value="向右" id="btn2">

? ? </div>

? ? <div class="slide" id="slide">

? ? ? ? <ul>

? ? ? ? ? ? <li>1</li>

? ? ? ? ? ? <li>2</li>

? ? ? ? ? ? <li>3</li>

? ? ? ? ? ? <li>4</li>

? ? ? ? ? ? <li>5</li>? ? ? ? ?

? ? ? ? </ul>

? ? </div>

</body>

</html>

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容