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=utf-8" />
    <title>无缝滚动</title>
    <style type="text/css">
    img{100px;float:left;}
    #content{100px;height:300px;overflow:hidden;}
    .pic01{100px;height:300px;}
    #content #pic img{float:left;}
    </style>
    <script type="text/javascript" src="jquery-1.8.3.min.js"></script>

    </head>
    <body>
    <div id="content">
    <div class="con" style="800px;">

    <div id="pic" class="pic01">
    <img src="1.jpg" alt="" />
    <img src="2.jpg" alt="" />
    <img src="3.jpg" alt="" />
    <img src="4.jpg" alt="" />
    </div>
    <div id="pic1" class="pic01"></div>
    </div>
    </div>
    <script type="text/javascript">
    $(document).ready(function(){
    var speed=20;
    var content=$("#content");
    var pic=$("#pic");
    var pic1=$("#pic1");
    pic1.html(pic.html());
    function marquee(){
    if(content.scrollTop()>=400){
    content.scrollTop(0)

    }else{
    content.scrollTop(content.scrollTop()+1)
    }

    }
    var scroll_ = setInterval(marquee,speed)
    content.mouseover(function(){
    clearInterval(scroll_)
    })
    content.mouseout(function(){
    scroll_ = setInterval(marquee,speed)
    })
    })
    </script>
    </body>
    </html>

    向左滚动:

    <!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=utf-8" />
    <title>无缝滚动</title>
    <style type="text/css">
    img{100px;float:left;}
    #content{300px;height:100px;overflow:hidden;}
    .pic01{400px;height:100px;float:left;}
    #content #pic img{float:left;}
    </style>
    <script type="text/javascript" src="jquery-1.8.3.min.js"></script>

    </head>
    <body>
    <div id="content">
    <div class="con" style="800px;">

    <div id="pic" class="pic01">
    <img src="1.jpg" alt="" />
    <img src="2.jpg" alt="" />
    <img src="3.jpg" alt="" />
    <img src="4.jpg" alt="" />
    </div>
    <div id="pic1" class="pic01"></div>
    </div>
    </div>
    <script type="text/javascript">
    $(document).ready(function(){
    var speed=20;
    var content=$("#content");
    var pic=$("#pic");
    var pic1=$("#pic1");
    pic1.html(pic.html());
    function Marquee(){
    if(content.scrollLeft()>=400){
    content.scrollLeft(0);
    }else{
    content.scrollLeft(content.scrollLeft()+1);
    }
    }

    var scroll_ = setInterval(Marquee,speed)
    content.mouseover(function() {
    clearInterval(scroll_);
    } )
    content.mouseout(function() {
    scroll_ = setInterval(Marquee,speed);
    } )
    })
    </script>
    </body>
    </html>

  • 相关阅读:
    WPF自定义控件
    NPOI设置Excel单元格字体、边框、对齐、背景色
    关于StreamReader.ReadToEnd方法
    ASP.NET Core Web多语言项目
    docker与虚拟机的区别
    C# Task.Run 和 Task.Factory.StartNew 区别
    MVC的SignalR例子
    深圳游玩攻略
    一个域名下多个Vue项目
    Linq的执行效率及优化
  • 原文地址:https://www.cnblogs.com/lixiaoxing/p/5019332.html
Copyright © 2011-2022 走看看