今天上班没事,就自己琢磨着写一下图片轮播,可是没想到,哈哈竟然写出来啦,下面就贴出来代码,作为纪念保存下下哈:

<body style="text-align: center;">
<div id="img" style="background: gray;opacity: 1;width: 100%;height: 600px;margin: 0 auto;position: relative;overflow: hidden;">
<div class="img1" style="width: 100%;height: 100%;position: absolute;left: -100%">
<img src="1.jpeg" style="background: yellow;width: 100%;height: 600px">
</div>
<div class="img2 ratato" style="float: left;position: absolute;width: 100%;height: 100%;left: 0">
<img src="2.jpg" style="background: red;width: 100%;height: 600px">
</div>
<div class="img3" style="float: left;position: absolute;width: 100%;height: 100%;left: 100%">
<img src="3.jpg" style="background: blue;width: 100%;height: 600px">
</div>
</div>
<div>
<a href="javascript:void(0);" onclick="up()">上一页</a>
<a href="javascript:void(0);" onclick="next()">下一页</a>
</div>
<script type="text/javascript">
var img1,img2,img3;//定义全局变量用来接收DOM对象
var t1,t2,t3,t;
$(function(){
t = setTimeout(function(){
test();
},4000)//延迟函数,带dom'准备就绪时间,延迟4秒执行test函数
// clearTimeout(t);
function test(){
$('.img2').animate({
left:'100%'
})//将class为img2的div通过动画向右移动整个容器的宽度,下面动画同理可得
$('.img1').animate({
left:'0px'
})
img3 = $('.img3').remove();
$("#img").prepend(img3);
img3.css('left','-100%')
t1 = setTimeout(function(){
test1();
},4000)
}
function test1(){
$('.img3').animate({
left:'0px'
})
$('.img1').animate({
left:'100%'
})
img2 = $('.img2').remove();
$('#img').prepend(img2);
img2.css('left','-100%')
t2 = setTimeout(function(){
test2()
},4000);
}
function test2(){
img2.animate({
left:'0px'
})
img3.animate({
left:'100%'
})
img1 = $('.img1').remove();
img1.css('left','-100%');
$('#img').prepend(img1);
t3 = setTimeout(function(){
test()
},4000)
}
}) // function up(){
// clearTimeout(t);
// clearTimeout(t1,t2,t3,t);
// var a = $('#img').children().eq(1);
// a.children().eq(0).attr('class','ratato');
// // a.attr('class','ratato');
// // a.animate({
// // left:'-100%'
// // })
// // a.next().animate({
// // left:'0px'
// // });
// // var next = a.prev().remove();
// // // alert(next.attr('class')); // // a.next().after(next); // // next.css(
// // 'left','100%'
// // )
// }
// function next(){ // }
</script>
</body>

html+jq实现简单的图片轮播的更多相关文章

  1. 使用jQuery做简单的图片轮播效果

      一.本特效主要用到的前端知识点 CSS中绝对定位(absolute)CSS实现垂直居中jQuery中简单的淡入淡出动画效果(fadeIn,fadeOut)定时器(setInterval,clear ...

  2. jq插件处女座 图片轮播

    好久没写博客了,变得好懒呀,无地自容.最近一直在学sass和jq插件的写法,照猫画虎的谢了一个jq的插件,也算是第一次真正称得上插件的插件 ,废话不多说 上代码 (function($) { $.fn ...

  3. JQuery简单实现图片轮播效果

    很多页面都需要用到界面轮播,但是用原生js相对来说比较复杂,用jQuery实现效果比较迅速,写个简单的demo 1.首先在HTML页面要放置轮播图案位置插入div,这里写了轮播图片数量为3张,所以定义 ...

  4. 纯JS写最简单的图片轮播

    非常简单的一个大图轮播,通过将控制显示位置来进行轮播效果,写来给正在学习的新手朋友们参考交流. 先看效果:(实际效果没有这么快) 先看布局: <div id="display" ...

  5. 【原生JS】写最简单的图片轮播

    非常简单的一个大图轮播,通过将控制显示位置来进行轮播效果,写来给正在学习的新手朋友们参考交流. 先看效果:(实际效果没有这么快) 先看布局: <div id="display" ...

  6. 用Vue实现一个简单的图片轮播

    本文已收录至https://github.com/likekk/studyBlog欢迎大家star,共同学习,共同进步.如果文章有错误的地方,欢迎大家指出.后期将在将GitHub上规划前端学习的路线和 ...

  7. 使用Handler和Timer+Timertask实现简单的图片轮播

    布局文件就只放了一个简单的ImageView,就不展示了. 下面是Activity package com.example.administrator.handlerthreadmessagedemo ...

  8. js实现简单的图片轮播

    js代码如下 <script type="text/javascript"> var n=1; var map=new Array(); map[0]=new Imag ...

  9. 纯CSS3代码实现简单的图片轮播

    以4张图片为例:1.基本布局:将4张图片左浮动横向并排放入一个div容器内,图片设置统一尺寸,div宽度设置4个图片的总尺寸,然后放入相框容器div,相框设置1个图片的大小并设置溢出隐藏,以保证正确显 ...

随机推荐

  1. Android实用代码块

    通过反射实现Menu显示图标 @Override public boolean onCreateOptionsMenu(Menu menu) { setIconEnable(menu, true); ...

  2. jQuery mini ui 2

    1.<a class="mini-button" iconCls="icon-add" onclick="addRow()" plai ...

  3. Jason 分享吴霁虹教授的产品模型

    产品的出现都是为了解决市场上存在的某一个”疼点“或一系列的”疼点“而出现. 疼点:是一个亟需待解决的问题,对应有相应的市场,会寻找相应的解决方案.比如:用户的小孩——>因为缺钱,所以担心小孩无法 ...

  4. PHP 初学者的学习线路和建议【1】

    先来看下PHP初学者的学习线路: (1) 熟悉HTML/CSS/JS等网页基本元素,完成阶段可自行制作简单的网页,对元素属性相对熟悉. (2) 理解动态语言的概念和运做机制,熟悉基本的PHP语法. ( ...

  5. 3D dungeon

    算法:广搜: 描述 You are trapped in a 3D dungeon and need to find the quickest way out! The dungeon is comp ...

  6. 转:测试用书(出处:cnblog--liangshi)

    列表格式为:图书分类.中文书名.英文书名.作者.排名不分先后,用红色标记出我推荐的书籍. 测试入门 软件测试(第2版) Software Testing (2e), Ron Patton 一本测试入门 ...

  7. android 手机信息获取

    1. adb已安装 2. adb shell getprop 此时已列出所有相关信息

  8. Bug :”解压压缩文件失败: cpio; 在头中不存在归档“

    问题描述: 在rpm包目录下执行rpm -ivh *rpm -force时,出现标题错误 解决办法: *src.rpm包也就源码包不能被直接进行安装,需要先将src.rpm包进行编译生成二进制的rpm ...

  9. Windows下python安装matplotlib

    此文为转载,原文地址为:http://blog.csdn.net/u010585135/article/details/42127273 一.下载matplotlib安装包:网址http://matp ...

  10. c++ string类型转换为char *类型

    string 是c++标准库里面其中一个,封装了对字符串的操作 把string转换为char* 有3中方法: 1.data 如: string str="abc"; char *p ...