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. The u32 classifier

    The u32 classifier The U32 filter is the most advanced filter available in the current implementatio ...

  2. (实用篇)PHPExcel读取Excel文件的实现代码

    用PHPExcel读取Excel 2007 或者Excel2003文件,需要的朋友,可以参考下. 涉及知识点:  php对excel文件进行循环读取 php对字符进行ascii编码转化,将字符转为十进 ...

  3. spring学习笔记---第三方SDK(Rest API)和Jaskson的巧用

    前言: 其实我以前一直不懂电商, 以及电商中所涉及的业务概念. 对于SKU等名词, 觉得有些玄乎. 对其背后的数据模型, 也有莫名的未知恐惧感: 庞大而理不清头绪. 不过最近有机会接触了微商(有赞), ...

  4. win10新增快捷键

    按此键   出现位置 重要程度 联想记忆 替代 用途 +A                    打开“操作中心” 右侧,   ★★★★★  Action    控制面板 ‌ +S           ...

  5. ZOJ 1101 Gamblers

    原题链接 题目大意:一群人聚众赌博.每个人先分别押注不同的金额,可以相互借钱.开奖之后,如果某个人的押注的金额正好等于任何其他三个人金额总和,那这个人就赢得其他三个人的赌注.如果同时有两个以上的赢家, ...

  6. ES6-函数扩展

  7. 关押罪犯(2010年NOIP全国联赛提高组)

    题目描述 Description S 城现有两座监狱,一共关押着N 名罪犯,编号分别为1~N.他们之间的关系自然也极 不和谐.很多罪犯之间甚至积怨已久,如果客观条件具备则随时可能爆发冲突.我们用&qu ...

  8. Linux网络管理概述

    概述:计算机基础知识.网络基础知识其实是所有的程序员所必须的,甚至已经不仅仅是程序员的专利,而是每一个人都应该掌握的计算机知识. 主要内容: 一.网络基础 二.Linux网络配置 三.Linux网络命 ...

  9. Android——进度对话框

    java类代码: //普通进度对话框 public void bt8_onClick(View v) { final ProgressDialog progressDialog = new Progr ...

  10. 作业:用HTML制作邮箱登陆界面

    <body leftmargin="200" rightmargin="200"> <font size="45" > ...