实现图片滚动

简要截图:

简要代码:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>滚动图片效果展示</title>
    <script src="http://cdn.bootcss.com/jquery/2.1.1/jquery.js"></script>
    <script src="http://cdn.bootcss.com/velocity/1.2.3/velocity.js"></script>
    <style type="text/css">
       div:not(:last-of-type){
           width:80%;height:750px;margin:0 auto;
       }
       div:first-of-type{background:url(imgs/1.jpg);background-size:cover;}
       div:nth-of-type(2){background:url(imgs/2.jpg);background-size:cover;}
       div:nth-of-type(3){background:url(imgs/3.jpg);background-size:cover;}
       div:nth-of-type(4){background:url(imgs/4.jpg);background-size:cover;}
       div:nth-of-type(5){background:url(imgs/5.jpg);background-size:cover;}
       div:nth-of-type(6){background:url(imgs/6.jpg);background-size:cover;}
       div:nth-of-type(7){background:url(imgs/7.jpg);background-size:cover;}
       div:last-of-type{position:fixed;top:130px;right:50px;}
       div:last-of-type ul{list-style:none;}
       div:last-of-type ul li{width:30px;height:30px;background:black;margin:3px;color:white;text-align:center;line-height:30px;}
        div:last-of-type ul li:hover {cursor:pointer; }

    </style>
</head>
<body>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div>
        <ul><li>1</li><li>2</li><li>3</li><li>4</li><li>5</li><li>6</li><li>7</li></ul>
    </div>
</body>
</html>
<script type="text/javascript">
    $("div:last ul li").click(function () {
        var numLi = $(this).text();
        $("div:last ul li").css({ "background-color": "black", "color": "white" });//每次都对所有的li背景色进行初始化,点击哪个改变哪个li的背景颜色和字体颜色
        switch (numLi) {
            case "1": $("div:first").velocity("scroll", { duration: 300 }); $(this).css({"background-color":"white","color":"black"});break;
            case "2": $("div:eq(1)").velocity("scroll", { duration: 300 }); $(this).css({ "background-color": "white", "color": "black" }); break;
            case "3": $("div:eq(2)").velocity("scroll", { duration: 300 }); $(this).css({ "background-color": "white", "color": "black" }); break;
            case "4": $("div:eq(3)").velocity("scroll", { duration: 300 }); $(this).css({ "background-color": "white", "color": "black" }); break;
            case "5": $("div:eq(4)").velocity("scroll", { duration: 300 }); $(this).css({ "background-color": "white", "color": "black" }); break;
            case "6": $("div:eq(5)").velocity("scroll", { duration: 300 }); $(this).css({ "background-color": "white", "color": "black" }); break;
            case "7": $("div:eq(6)").velocity("scroll", { duration: 300 }); $(this).css({ "background-color": "white", "color": "black" }); break;

        }
    });

</script>
时间: 2024-07-28 14:16:08

实现图片滚动的相关文章

随机图片滚动(随机数+变化函数),可运行

<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>随机图片滚动</title> <!--可成功执行,布局有点混乱...懒得改了.需要一个js文件,在上一文章中有--> <style type="text/css"> *{ padding:0; margin: 0;

原生js实现tab选项卡里内嵌图片滚动特效代码

<!DOCTYPE HTML><html lang="en-US"><head><meta charset="UTF-8"><title>原生js实现tab选项卡里内嵌图片滚动特效代码</title><meta name="keywords" content="原生js实现tab选项卡里内嵌图片滚动特效代码" /><meta name=&

jquery mobile的一些插件(图片滚动)

jquery mobile的一些插件(图片滚动) 1,photoswipe 网址:http://www.photoswipe.com/demo: http://www.photoswipe.com/latest/examples/04-jquery-mobile.html个人描述:在手机上操作很流畅,能自使用屏幕尺寸,竖屏显示效果很好,横屏图片太大了,也就是列数固定的原因. 2,Touch-Gallery 网址:http://neteye.github.com/touch-gallery.htm

Android高级图片滚动控件,编写3D版的图片轮播器

转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/17482089 大家好,好久不见了,最近由于工作特别繁忙,已经有一个多月的时间没写博客了,我也是深感惭愧.那么今天的这篇既然是阔别了一个多月的文章,当然要带来更加给力点的内容了,那么话不多说,赶快进入到今天的正题吧. 说 到图片轮播器,很多的Android应用中都会带有这个功能,比如说网易新闻.淘宝等.最新我们公司的一款应用也加入了这个功能,并且在图片轮播的基础上 还增加了三维立体

12-25 学习图片滚动器

// //  ViewController.m //  图片滚动器 // //  Created by Mac on 15/12/25. //  Copyright © 2015年 Mac. All rights reserved. // #import "ViewController.h" @interface ViewController () <UIScrollViewDelegate> //从stroyboad中拖来的控件 @property (weak, nona

android 背景图片滚动

昨天在给客户端做天气展示页面的时候,发现很多app的天气页面背景图片都会缓慢移动,形成了一种3d的感觉.例如下雨,静态图片缓慢移动,雨滴位置变换感觉就真的在下雨.云朵的移动也很酷.于是研究了一下午.写了一个自定义view控件. 我的自定义控件继承了view,重写ondraw方法.本人C#转android才3个月,以下代码如有错或者有可以改进的地方,请各位在评论中指出.望不吝赐教! ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

图片滚动(待美化)

1:原有图片4张,无论向左或者向右滚动,都会出现空白,所以需要在原有4张图片的基础下自加得到8张图片, 2:向左滚动:当图片滚到到整个ul宽度的一半时(aDiv.offsetLeft<-aDiv.offsetWidth/2) 将整个ul的左边距置0(aDiv.style.left='0px';),通俗说即将整个图片从左往右第一张图片拉倒最开始的位置. 3:向右滚动:当图片滚动到ul的左边距大于0时(aDiv.offsetLeft>0) 将整个ul的左边距设为整个ul宽度的一半(aDiv.sty

JS 图片滚动懒加载

基本原理 图片滚动懒加载的原理非常简单:基于<img>标签,在初次加载时,不把图片url放在src属性中,而是自定义一个属性,例如data-src.然后检测"scroll","resize"等窗体事件,判断图片是否进入了可视范围.如果进入,则将data-src的字段替换到src,此时浏览器会自动去加载对应图片资源. 首先是不添加src的img标签,新增data-src用于放置图片url: <img class="lazyImg"

常用JS图片滚动(无缝、平滑、上下左右滚动)代码大全

常用JS图片滚动(无缝.平滑.上下左右滚动)代码大全 今天刚网上看的 不多说直接帖代码---- <head><-----></head><body> <!--向下滚动代码开始--><div id="colee" style="overflow:hidden;height:253px;width:410px;"><div id="colee1"><p>&

wap图片滚动特效_无css3 元素js脚本编写

手机图片滑动切换,网上有很多这样的例子,但都借助于其他组件,让代码混乱的不行:还有就是用到css3里的 transform:translate(x,y);移动元素,不过发现在不支持css3的设备上马上完蛋了,所 有下定决心自己做一个,谁知出现了很多的问题,其中最重要的是给图片加链接,网页中的上下滚动条不能在拖动图片的时候滚动,并且不能兼容pc机器上的拖动:在这里就简单介绍一下遇到的问题和解决的方法: 问题一:给图片加上链接后,在拖动的时候总是跳到其他页面: 问题根源主要是不能判断是点击还是拖动,