Html代码 :

<div class="v_out v_out_p">
<div class="prev">
<a href="javascript:void(0)"></a>
</div>
<div class="v_show">
<div class="v_cont">
<ul>
<li index="0" style="background: #f00">[第1讲]</li>
<li index="1" style="background: #ff0">[第2讲]</li>
<li index="2" style="background: #f0f">[第3讲]</li>
<li index="3" style="background: #999">[第4讲]</li>
<li index="4" style="background: #666">[第5讲]</li>
</ul>
</div>
</div>
<div class="next">
<a href="javascript:void(0)"></a>
</div>
<ul class="circle">
<li class="circle-cur">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
</div>
<script type="text/javascript">

$(function () {

/*======next======*/
$(".next a").click(function () { nextscroll() });

function nextscroll() {

var vcon = $(".v_cont ");
var offset = ($(".v_cont li").width()) * -1;

vcon.stop().animate({ left: offset }, "slow", function () {

var firstItem = $(".v_cont ul li").first();
vcon.find("ul").append(firstItem);
$(this).css("left", "0px");

circle()

});

};

function circle() {

var currentItem = $(".v_cont ul li").first();
var currentIndex = currentItem.attr("index");

$(".circle li").removeClass("circle-cur");
$(".circle li").eq(currentIndex).addClass("circle-cur");

}

//setInterval(nextscroll,2000)

/*======prev======*/
$(".prev a").click(function () {

var vcon = $(".v_cont ");
var offset = ($(".v_cont li").width() * -1);

var lastItem = $(".v_cont ul li").last();
vcon.find("ul").prepend(lastItem);
vcon.css("left", offset);
vcon.animate({ left: "0px" }, "slow", function () {
circle()
})

});

/*======btn====circle======*/
var animateEnd = 1;

$(".circle li").click(function () {

if (animateEnd == 0) { return; }

$(this).addClass("circle-cur").siblings().removeClass("circle-cur");

var nextindex = $(this).index();
var currentindex = $(".v_cont li").first().attr("index");
var curr = $(".v_cont li").first().clone();

if (nextindex > currentindex) {

for (var i = 0; i < nextindex - currentindex; i++) {

var firstItem = $(".v_cont li").first();
$(".v_cont ul").append(firstItem);

}

$(".v_cont ul").prepend(curr);

var offset = ($(".v_cont li").width()) * -1;

if (animateEnd == 1) {

animateEnd = 0;
$(".v_cont").stop().animate({ left: offset }, "slow", function () {

$(".v_cont ul li").first().remove();
$(".v_cont").css("left", "0px");
animateEnd = 1;

});

}

} else {

var curt = $(".v_cont li").last().clone();

for (var i = 0; i < currentindex - nextindex; i++) {
var lastItem = $(".v_cont li").last();
$(".v_cont ul").prepend(lastItem);
}

$(".v_cont ul").append(curt);

var offset = ($(".v_cont li").width()) * -1;

$(".v_cont").css("left", offset);

if (animateEnd == 1) {

animateEnd = 0;
$(".v_cont").stop().animate({ left: "0px" }, "slow", function () {

$(".v_cont ul li").last().remove();
animateEnd = 1;
});
}
}
});
})
</script>

============================================================================================================

css代码:

*
{
margin: 0px;
padding: 0px;
list-style-type: none;
}
.v_out
{
width: 748px;
margin: 20px auto;
overflow: hidden;
}
.v_show
{
width: 665px;
overflow: hidden;
position: relative;
height: 280px;
float: left;
}
.v_cont
{
width: 6650px;
position: absolute;
left: 0px;
top: 0px;
}
.v_cont ul
{
float: left;
text-align: center;
line-height: 50px;
}
.v_cont ul li
{
width: 665px;
height: 250px;
background: #f8f8f8;
float: left;
margin-top: 3px;
}

/*---圆圈---*/
.v_out_p
{
position: relative;
overflow: visible;
}
.circle
{
position: absolute;
left: 40px;
top: 290px;
}
.circle li
{
width: 120px;
height: 60px;
float: left;
margin-right: 10px;
background: #ccc;
}
.circle .circle-cur
{
background: #f00;
}

/*---切换---*/
.prev, .next
{
float: left;
padding: 105px 9px 0;
}
.prev a
{
background: #f00;
}
.prev .ico_1
{
background: url(input_a.gif) no-repeat 0 -3757px;
}

.next a
{
background: #f00;
}
.next .ico_2
{
background: url(input_a.gif) no-repeat right -3757px;
}
.prev, .prev a, .next, .next a
{
width: 21px;
height: 28px;
display: block;
}

Javascript 图片左右滑动与切换的更多相关文章

  1. 基于jQuery图片遮罩滑动文字切换特效

    基于jQuery图片遮罩滑动文字切换特效.这是一款jquery hover鼠标滑动选项卡切换透明背景遮罩文字显示特效.效果图如下: 在线预览   源码下载 实现的代码. html代码: <div ...

  2. javascript图片切换

    JavaScript 图片滑动切换效果 作者:cloudgamer 时间: 2009-09-25 文档类型:原创 来自:蓝色理想 第 1 页 JavaScript 图片滑动切换效果 [1] 第 2 页 ...

  3. 高仿优酷Android客户端图片左右滑动(自动切换)

    本例是用ViewPager去做的实现,支持自动滑动和手动滑动,不仅优酷网,实际上有很多商城和门户网站都有类似的实现: 具体思路: 1. 工程中需要添加android-support-v4.jar,才能 ...

  4. Javascript图片预加载详解

    预加载图片是提高用户体验的一个很好方法.图片预先加载到浏览器中,访问者便可顺利地在你的网站上冲浪,并享受到极快的加载速度.这对图片画廊及图片占据很大比例的网站来说十分有利,它保证了图片快速.无缝地发布 ...

  5. 仿优酷Android客户端图片左右滑动(自动滑动)

    最终效果: 页面布局main.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayou ...

  6. 图片轮播(左右切换)--JS原生和jQuery实现

    图片轮播(左右切换)--js原生和jquery实现 左右切换的做法基本步骤跟 上一篇文章  淡入淡出 类似,只不过修改了一些特定的部分 (1)首先是页面的结构部分 对于我这种左右切换式 1.首先是个外 ...

  7. javascript - 图片的幻灯片效果

    javascript 代码: <script type="text/javascript"> function select_play() { var select_p ...

  8. Javascript图片预加载详解 分类: JavaScript HTML+CSS 2015-05-29 11:01 768人阅读 评论(0) 收藏

    预加载图片是提高用户体验的一个很好方法.图片预先加载到浏览器中,访问者便可顺利地在你的网站上冲浪,并享受到极快的加载速度.这对图片画廊及图片占据很大比例的网站来说十分有利,它保证了图片快速.无缝地发布 ...

  9. JavaScript banner轮播 左右切换 圆点点击切换

    1.效果如下图: 2.源码如下: <!DOCTYPE html> <html lang="en"> <head> <meta charse ...

随机推荐

  1. Sublime Text 2 安装主题的方法

    主题下载 下载一个主题,例如: https://github.com/hyspace/st2-reeder-theme 里面起作用的文件有两个: Reeder.sublime-theme Earths ...

  2. 刚查了,Z3795不支持EPT,即WP8开发必须的SLAT,看来只能作为简单的WINDOWS备机了

    刚查了,Z3795不支持EPT,即WP8开发必须的SLAT,看来只能作为简单的WINDOWS备机了,也就只能做做文档编辑,脚本编写之类的. 数据来源 http://ark.intel.com/zh-C ...

  3. Hibernate控制insert\update语句

  4. Android——ListView

    1.ArryAdapter: arry_adapter的layout文件: <?xml version="1.0" encoding="utf-8"?&g ...

  5. poj1456 结构体排序+贪心

    题意:给出很多商品,每个商品有价值和出售期限,只能在期限内出售才能获取利润,每一个单位时间只能出售一种商品,问最多能获得多少利润. 只需要按照优先价值大的,其次时间长的排序所有物品,然后贪心选择,从它 ...

  6. https那些事儿

    (一)SSL/TLS协议运行机制的概述 一.作用 不使用SSL/TLS的HTTP通信,就是不加密的通信.所有信息明文传播,带来了三大风险. (1) 窃听风险(eavesdropping):第三方可以获 ...

  7. web开发注意的问题

    1.<input type="submit" value="提交">    将表单提交<form action="login.jsp ...

  8. Linux-SSL和SSH和OpenSSH,OpenSSL有什么区别

    ssl是通讯链路的附加层.可以包含很多协议.https, ftps, ..... ssh只是加密的shell,最初是用来替代telnet的.通过port forward,也可以让其他协议通过ssh的隧 ...

  9. PHP GC垃圾回收机制之引用变量回收周期疑问

    普通的引用变量的销毁大家都知道, 当unset的时候如果refcount = 0 则认为无用, 销毁. 但是手册中提到一点会有递归引用的问题,很是奇葩 代码如下 <?php $a = 1; $a ...

  10. JavaScript对SVG进行操作的相关技术

    原文地址:http://www.ibm.com/developerworks/cn/xml/x-svgscript/   本文主要介绍在 SVG 中通过编程实现动态操作 SVG 图像的知识. SVG ...