简单图片banner轮播
/**************【css】****************/
<style type="text/css">
*{margin:0px;padding:0px;}
.banner{width:100%;height:300px;background:rgb(63,12,9);position:relative;}
.cont{width:760px;height:300px;margin:0px auto;background:#cc9999;position:relative;}
.cont ul li{list-style-type:none;width:760px;height:300px;position:absolute;top:0px;left:0px;display:none;}
.cont .prev{width:50px;height:55px;position:absolute;top:100px; left:0px;background:url("images1/button-prev-next.png");background-position:60px -140px;display:none;cursor:pointer;}
.cont .next{width:50px;height:55px;position:absolute;top:100px; right:0px;background:url("images1/button-prev-next.png");background-position:-60px -140px;display:none;cursor:pointer;}
.motbig{width:175px;height:17px;position:absolute;bottom:10px;left:0px;right:0px;margin:0px auto;list-style-type:none;}
.motbig ul li{list-style-type:none;width:12px;height:12px;border:1px #ffffff solid;float:left;margin:1px 5px;border-radius:50%;cursor:pointer;}
.motbig ul li.hover{background:#fff;}
</style>
/*****************************/
/************【布局】*************/
<div class="banner">
<div class="cont">
<ul>
<li style="display:block;" barbg="rgb(63,12,9)">
<img src="../images1/1.jpg" alt="" />
</li>
<li barbg="rgb(4, 28, 98)">
<img src="../images1/2.jpg" alt="" />
</li>
<li barbg="rgb(134, 162, 210)">
<img src="../images1/3.png" alt="" />
</li>
<li barbg="rgb(215, 222, 228)">
<img src="../images1/4.jpg" alt="" />
</li>
<li barbg="rgb(140, 150, 212)">
<img src="../images1/5.jpg" alt="" />
</li>
<li barbg="rgb(12, 18, 34)">
<img src="../images1/6.jpg" alt="" />
</li>
<li barbg="rgb(56, 162, 210)">
<img src="../images1/7.jpg" alt="" />
</li>
</ul>
<div class="prev"></div>
<div class="next"></div>
</div>
<div class="motbig">
<ul>
<li class="hover"></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</div>
/*******************************************/
<script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
/************【js】*******************/
<script type="text/javascript">
var _index = 0;
var time;
//点击小圆点按钮切换图片
$(".motbig ul li").click(function () {
$(this).addClass("hover").siblings().removeClass("hover");
_index = $(this).index(); //获取当前序号
play(_index);
})
//向左切换
$(".cont .prev").click(function () {
_index--;
if (_index < 0) { _index = 6; }
play(_index);
$(".motbig ul li").eq(_index).addClass("hover").siblings().removeClass("hover");
})
//向右切换
$(".cont .next").click(function () {
autoPaly();
})
function autoPaly() {
_index++;
if (_index > 6) { _index = 0; }
play(_index);
$(".motbig ul li").eq(_index).addClass("hover").siblings().removeClass("hover");
}
function play(_index) {
var bg = $(".cont ul li").eq(_index).attr("barbg");
$(".banner").css({ background: bg });
$(".cont ul li").eq(_index).fadeIn().siblings().fadeOut();
}
//移动到banner区域显示左右切换按钮,移开banner区域隐藏左右切换按钮
$(".cont").hover(function () {
$(".cont .prev").show();
$(".cont .next").show();
clearInterval(time);
}, function () {
$(".cont .prev").hide();
$(".cont .next").hide();
time = setInterval("autoPaly()", 3000);
});
time=setInterval("autoPaly()", 3000);
</script>
/*****************************/
效果:

简单图片banner轮播的更多相关文章
- 基于Jquery的banner轮播插件,简单粗暴
新手练习封装插件,觉着在前端这一块的轮播比较多,各种旋转木马一类的3D旋转,技术不够,所以封装了一个简单的banner轮播插件,功能也比较简单,就是左右向的轮播. 先挂地址https://github ...
- 分别用css3、JS实现图片简单的无缝轮播功效
本文主要介绍分别使用CSS3.JS实现图片简单无缝轮播功效: 一.使用CSS3实现:利用animation属性 (实现一张一张的轮播,肉眼只看见一张图片) HTML部分比较简单,两个div下包着几个i ...
- 安卓开发笔记(三十二):banner轮播图的实现
一.activity.xml 我这里主要爬取的爱奇艺首页的图片进行轮播,应用了两个github上的开源库,一个banner的库,一个加载网络图片的库,用开源库能够极大地节省我们编写代码的时间. < ...
- iOS开发之三个Button实现图片无限轮播(参考手机淘宝,Swift版)
这两天使用Reveal工具查看"手机淘宝"App的UI层次时,发现其图片轮播使用了三个UIButton的复用来实现的图片循环无缝滚动.于是乎就有了今天这篇博客,看到“手机淘宝”这个 ...
- Android中使用ImageViewSwitcher实现图片切换轮播导航效果
前面写过了使用ViewFlipper和ViewPager实现屏幕中视图切换的效果(ViewPager未实现轮播)附链接: Android中使用ViewFlipper实现屏幕切换 Android中使用V ...
- iOS开发之ImageView复用实现图片无限轮播
在上篇博客中iOS开发之多图片无缝滚动组件封装与使用给出了图片无限轮播的实现方案之一,下面在给出另一种解决方案.今天博客中要说的就是在ScrollView上贴两个ImageView, 把ImageVi ...
- 一步一步拆解一个简单的iOS轮播图(三图)
导言(可以不看): 不吹不黑,也许是东半球最简单的iOS轮播图拆分注释(讲解不敢当)了(tree new bee).(一句话包含两个人,你能猜到有谁吗?提示:一个在卖手机,一个最近在卖书)哈哈... ...
- jQuery图片无缝轮播插件;
图片轮播这种效果在web开发中看常见,网上的插件也有很多,最近在整理项目的过程中,把之前的图片轮播效果整合了一下,整理成一个可调用的插件以做记录,也方便更多前端爱好者来学习使用:图片的轮播原理很简单, ...
- jQuery与原生js实现banner轮播图
jQuery与原生js实现banner轮播图: (jq需自己加载)(图片需自己加载) <!DOCTYPE html> <html> <head> <meta ...
随机推荐
- iOS常用的加密方式--备用
MD5 iOS代码加密 创建MD5类,代码如下 #import <Foundation/Foundation.h> @interface CJMD5 : NSObject +(NSStri ...
- 转:几十种编程语言的快速入门教程- learnxinyminutes.com
原文来自于:http://top.jobbole.com/15551/ 这家网站的名称是 Learn X in Y minutes,包括了几十种编程语言的快速学习入门教程.打开几种编程语言来看了一下, ...
- MFC之MessageBox用法
一 函数原型及参数 function MessageBox(hWnd: HWND; Text, Caption: PChar; Type: Word): Integer; hWnd:对话框父窗口 ...
- github继续折腾
又在折腾github了,本来以前在neworiginou这个github上上传过项目的: 现在想在另一个github上joely上传项目,发现按以前的流程做个测试,居然没能上传成功! 经发现,以前的n ...
- AndroidStudio SVN检出
版本管理是每个项目的必经之路,很多的ADT都会集成版本管理插件.AS也同样可以集成GITHUB和SVN插件.github对项目有一定的限制,而SVN就比较开放了,所以我们在用AS开发的时候一般用SVN ...
- 图论(网络流,分数规划):COGS 2047. [ZOJ2676]网络战争
2047. [ZOJ2676]网络战争 ★★★ 输入文件:networkwar.in 输出文件:networkwar.out 评测插件 时间限制:5 s 内存限制:32 MB [题目描 ...
- 线性代数(矩阵乘法):POJ 3233 Matrix Power Series
Matrix Power Series Description Given a n × n matrix A and a positive integer k, find the sum S = ...
- 【拓扑】【宽搜】CSU 1084 有向无环图 (2016湖南省第十二届大学生计算机程序设计竞赛)
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1804 题目大意: 一个有向无环图(DAG),有N个点M条有向边(N,M<=105 ...
- HDOJ 2052 Picture
Problem Description Give you the width and height of the rectangle,darw it. Input Input contains a n ...
- Sublime Text 3安装与使用 Package Control 插件安装
原文地址:http://www.cnblogs.com/zhcncn/p/4113589.html 本文是Sublime Text 全程指引 by Lucida (http://www.cnblogs ...