基于JQuery的渐隐渐现轮播
<div id="ads">
<div>
<!--轮播图片-->
<ul>
<li><a href="#" target="_blank"><img alt="" src="" /></a></li>
<li><a href="#" target="_blank"><img alt="" src="" /></a></li>
<li><a href="#" target="_blank"><img alt="" src="" /></a></li>
<li><a href="#" target="_blank"><img alt="" src="" /></a></li>
</ul>
<!--左右切换箭头-->
<div>
<div><img alt="" src="" /></div>
<div><img alt="" src="" /></div>
</div>
</div>
<!--导航小圆点-->
<ul>
<li class="focus"></li>
<li></li>
<li></li>
<li class="lastLi"></li>
</ul>
</div>
li{display: inline-block; float: left;}
.lastLi{margin-right: 0 !important;}
#ads{position: relative; margin-bottom:33px; width:100%; min-width: 1210px;height:512px;overflow: hidden;z-index:;}
#ads>div{position:relative; margin:0 auto; width:inherit; min-width:1210px; height:inherit;}
#ads>div>ul>li{display:none; position: absolute;top:;left:50%;margin-left:-960px; z-index:;}
#ads>div>ul>li:first-child{display:block;}
#ads>div>div{position:relative; width:1210px; height:290px; margin:0 auto;}
#ads>div>div>div{position:absolute; display:none; top:222px; right:; width:67px; height:67px; cursor:pointer;z-index:; }
#ads>div>div>div:first-child{left:;}
#ads>ul{
position: absolute;
top: 480px;
left: 50%;
margin:0 0 0 -26px;
padding:;
z-index:;
}
#ads>ul>li{
margin-right: 8px;
padding:;
width: 9px;
height: 9px;
border-radius: 10px;
cursor: pointer;
background:url() 0 0 no-repeat;
}
#ads>ul>li.focus{
background:url() 0 -9px no-repeat;
}
;(function(){
var setting = {
$ads:$("#ads"),
$adsContent: $("#ads>div>ul>li"),//大广告
$arrows: $("#ads>div>div>div"),//切换箭头
$markPoints: $("#ads>ul>li"),//小圆点
HIDETIME:400,//消失时间
SHOWTIME:800,//出现时间
INTERVALTIME:4000,//间隔时间
animaChoice:0//0代表渐隐渐现,1代表滚动
},
currentIndex=0,
len = setting.$adsContent.length,
_setInterval=setInterval(autoPlay,setting.INTERVALTIME);
setting.$ads.hover(function(){
setting.$arrows.fadeIn("fast").css("display","inline-block");
},function(){
setting.$arrows.fadeOut("fast");
});
//向右切换
function autoPlay(){
switchAds(0,false);
}
//点击箭头切换
setting.$arrows.each(function(index){
if(index==0){
$(this).on("click",function(){
switchAds(1,true);
});
}
else{
$(this).on("click",function(){
switchAds(0,true);
});
}
})
//点击小圆点切换
setting.$markPoints.each(function(index){
$(this).on("click",function(){
switchAds(2,true,index);
})
})
//切换
function switchAds(clickStatus,beClicked,index){
if(beClicked) setting.$adsContent.stop(false,true);
if(!setting.$adsContent.is(":animated")){
if(beClicked) clearInterval(_setInterval);
animate(setting.$adsContent.eq(currentIndex),false,setting.animaChoice);
switch(clickStatus){
case 0://选择下一张
currentIndex++;
break;
case 1://选择前一张
currentIndex--;
break;
case 2://选择被点击的
currentIndex=index;
break;
default:
break;
}
if(currentIndex==len) currentIndex=0;
else if(currentIndex==-1) currentIndex=len-1;
//console.log(currentIndex);
animate(setting.$adsContent.eq(currentIndex),true,setting.animaChoice);
markDot(setting.$markPoints.eq(currentIndex));
if(beClicked) _setInterval=setInterval(autoPlay,setting.INTERVALTIME);
}
}
//负责标记小圆点
function markDot($target){
$target.addClass("focus").siblings().removeClass("focus");
}
//负责动画效果
function animate($target,show,animaChoice){
switch(animaChoice){
case 0:
if(show) $target.fadeIn(setting.SHOWTIME);
else $target.fadeOut(setting.SHOWTIME);
break;
case 1:
if(show) ;
else ;
break;
default:
break;
}
}
})()
基于JQuery的渐隐渐现轮播的更多相关文章
- 基于jQuery可悬停控制图片轮播代码
基于jQuery可悬停控制图片轮播代码.这是一款可悬停切换全屏轮播jQuery幻灯片.效果图如下: 在线预览 源码下载 实现的代码: <!-- 轮播广告 --> <div id= ...
- 基于jQuery游戏网站焦点图轮播特效
基于jQuery的一款游戏网站焦点图轮播特效.这是一款带进度条定时切换,带缩略图切换的jQuery网站焦点图代码.效果图如下: 在线预览 源码下载 实现的代码. html代码: <cente ...
- js渐隐渐现透明度变化淡入淡出轮播图
js渐隐渐现透明度变化淡入淡出轮播图.焦点图 一些广告banner展示常见. (附件) <!DOCTYPE html> <html> <head> <meta ...
- jQuery鼠标悬停文字渐隐渐现动画效果
jQuery鼠标悬停文字渐隐渐现动画效果 当时是做项目的时候用到的所以图片有些大,九张,真正要做图片不需要这么大 css样式 <style> *{ margin: 0; padding: ...
- WPF 渐隐渐现切换背景图片
最近学习WPF,尝试着自己做一些小玩意,也遇到了一些问题,于是整理记录以便日后查阅. 我们都知道WPF可以实现一些很炫的效果,然而有时候为达到这个目的却并不是一件很容易的事情.比如:在软件中我希望能够 ...
- UGUI 实现界面 渐隐渐现 FadeIn/Out 效果
孙广东 2015.7.10 事实上熟悉NGUI的人,应该知道 实现渐隐渐现 FadeIn/Out 效果是非常方便的,由于父对象 的 改变会自己主动影响到子对象. 比方 UIWidget.UIPan ...
- jquery特效(5)—轮播图③(鼠标悬浮停止轮播)
今天很无聊,就接着写轮播图了,需要说明一下,这次的轮播图是在上次随笔中jquery特效(3)—轮播图①(手动点击轮播)和jquery特效(4)—轮播图②(定时自动轮播)的基础上写出来的,也就是本次随笔 ...
- jquery特效(4)—轮播图②(定时自动轮播)
周末出去逛完街,就回公司好好地研究代码了,也算是把定时自动轮播程序写出来了,特意说明一下,这次的轮播图是在昨天随笔中jquery特效(3)—轮播图①(手动点击轮播)的基础上写出来的,也就是本次随笔展示 ...
- 在Unity5中使用C#脚本实现UI的下滑、变色、渐隐渐现效果
一.首先,我们先创建一个Text 依次选择Component→UI→Text创建一个Text,创建完成后如下: 二.创建完成后,在Project面板点击Create→C# Script,本例命名 ...
随机推荐
- 11.聚合(Aggregation)
聚合关系是关联关系的一种特例,它体现的是整体与部分的关系,即has-a的关系,此时整体与部分之间是可分离的,它们可以具有各自的生命周期.比如计算机与CPU.公司与员工的关系等.表现在代码层面,和关联关 ...
- JS 去字符串空格
str为要去除空格的字符串:去除所有空格: str = str.replace(/\s+/g,""); 去除两头空格: str = str.replace(/^\s+|\s+$/g ...
- uva539 The Settlers of Catan
The Settlers of Catan Within Settlers of Catan, the 1995 German game of the year, players attempt to ...
- Python int与string之间的转化
string-->int 1.10进制string转化为int int('12') 2.16进制string转化为int int('12', 16) int-->string 1.int转 ...
- C# RSA和Java RSA互通
今天调查了C# RSA和Java RSA,网上很多人说,C#加密或者java加密 ,Java不能解密或者C#不能解密 但是我尝试了一下,发现是可以的,下面就是我尝试的代码,如果您有什么问题,我想看看, ...
- C++ Code_animateCtrl
Code:: 播放 if (!m_animate1.Open("C:\\copy.avi")) { MessageBox("NULL& ...
- [AngularJS] Accessing Data in HTML -- controllerAs, using promises
<!DOCTYPE html> <html> <head> <title>Access Data From HTML</title> < ...
- Repeater的ItemCreated和ItemDataBind的区别
Repeater 的ItemCreated的事件在第一次调用DataBind方法的时候触发,即在(IsPostBack==false)的时候才调用,当页面回滚是将不是调用该方法(错误的源头).而Ite ...
- 深入理解 CSS 中的行高与基线
1.基本概念 1. 基线.底线.顶线.中线 注意:基线(base line)并不是汉字文字的下端沿,而是英文字母“x”的下端沿. 2. 内容区 内容区是指底线和顶线包裹的区域(行内元素display ...
- Qt组件中的双缓冲无闪烁绘图
双缓冲绘图在Qt4中,所有的窗口部件默认都使用双缓冲进行绘图.使用双缓冲,可以减轻绘制的闪烁感.在有些情况下,用户要关闭双缓冲,自己管理绘图.下面的语句设置了窗口部件的Qt::WA_PaintOn ...