轮播图jq
来源:互联网 发布:淘宝买的酒是真的吗 编辑:程序博客网 时间:2024/06/04 00:59
轮播图
*{
margin: 0; /*去外边框,不同组件之间的距离*/padding: 0; /*组件内边框*/
}
body{
margin: 100px;
}
.wrap{
height:400px;
width:500px;
background-color:red;
overflow: hidden; /*对此区域包含多余部分隐藏*/
border: 3px solid #f00; /*对边框的设置*/
/*position:relative;*/
}
li{
list-style-type:none; /*去掉菜单序号*/
}
.wrap ul{
width: 2500px;
/*position: absolute;*/
left: 0;
top: 0;
}
.wrap ul li{
float: left;
width: 500px;
}
.wrap ol{
/*position: absolute;*/
bottom: 20px;
right: 10px;
}
.wrap ol li{
float: left;
width: 16px;
height: 16px;
line-height: 16px; /*行高*/
text-align: center;
border: 1px solid #fc0; /*对序号边框设置*/
background: #000;
color: #fff;
margin-right:10px;
cursor: pointer; /*cursor:hand 与 cursor:pointer 的效果是一样的,都像光标指向链接一样,光标变成手行,*/
}
.wrap ol li.current{
background: #fff;
color: #000;
}
.wrap .introduce{
height: 30px;
line-height: 30px;
width: 350px;
background: rgba(0,0,0,0.5);
color: #fff;
position: absolute;
bottom: 10px;
left: 0;
/*opacity: 0.5;
filter:alpha(opacity=50); */
}
----------------------
js:
$(function(){
var oul = $('.wrap ul');
var ali = $('.wrap ul li');
var numLi = $('.wrap ol li');
var aliWidth = $('.wrap ul li').eq(0).width();
var _now = 0; //这个是控制数字样式的计数器
var _now2 = 0;//这个是控制图片运动距离的计数器
var timeId;
var aimg = $('.wrap ul img');
var op = $('.wrap p');
numLi.click(function(){
var index = $(this).index();
_now = index;
_now2=index;
var imgAlt = aimg.eq(_now).attr('alt');
op.html(imgAlt);
$(this).addClass('current').siblings().removeClass();
oul.animate({'left':-aliWidth*index},500);
});
/**
* [slider description] 图片运动的函数
* @return {[type]} [description] 无返回值
*/
function slider(){ //序号滚动效果
if(_now==numLi.size()-1){ //到最后时跳到第一张
ali.eq(0).css({
'position':'relative',
'left': oul.width()
});
_now=0;
}else{
_now++;
}
_now2++;
numLi.eq(_now).addClass('current').siblings().removeClass();
var imgAlt = aimg.eq(_now).attr('alt');
op.html(imgAlt);
oul.animate({'left':-aliWidth*_now2},500,function(){
if(_now==0){
ali.eq(0).css('position','static');
oul.css('left',0);
_now2=0;
}
});
}
timeId = setInterval(slider,1500);
/*$('.wrap').mouseover(function(){
clearInterval(timeId);
});
$('.wrap').mouseout(function(){
timeId = setInterval(slider,1500);
});*/
$('.wrap').hover(function(){
clearInterval(timeId);
},function(){
timeId = setInterval(slider,1500);
});
});
dom:
<body>
<div class="wrap">
<ul>
<li><img src="1.jpg" alt="傅家俊"></li>
<li><img src="2.jpg" alt="Stephen Maguire"></li>
<li><img src="3.jpg" alt="Mark Selby"></li>
<li><img src="4.jpg" alt="丁俊晖"></li>
<li><img src="5.jpg" alt="猜猜这个高富帅是who?"></li>
</ul>
<ol>
<li class="current">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ol>
<p class="introduce">111111</p>
</div>
- jq 轮播图
- jq-轮播图
- jQ 轮播图
- JQ轮播图
- 轮播图jq
- JQ轮播图
- 轮播图2(jQ)
- 轮播图-好代码-(jq)
- jq淡入淡出轮播图
- jq写一个轮播图
- 简易的JQ轮播图
- 封装轮播图jq
- JS+JQ轮播图插件
- JQ传统轮播图
- JQ传统轮播图
- jQ传统轮播图
- jQ
- jQ
- apt-get remove 用法详解
- 神经网络
- IAR Warning[Pe223]: function 'assert_param' declared implicitly 解决方法
- mybatis配置文件中小于大于号的处理
- 代替Excel上载的方法
- 轮播图jq
- SQL Server 扩展属性
- ==与equal区别
- 设计模式之--简单工厂模式
- 设计模式的应用场景(10)--桥模式
- github上传步骤
- getDimension,getDimensionPixelOffset和getDimensionPixelSize区别
- Python、R、Java、 C++ 等:从业界反馈看机器学习语言趋势
- Java9正则表达式新特性