JQ主页图片划动切换效果
.wrapper { width: 726px; float: left; }
#jiao_dian { width: 980px; *height: 292px; margin-top: 10px; margin-right: auto; margin-bottom: 0; margin-left: auto; }
#focus { width: 726px; height: 280px; overflow: hidden; position: relative; }
#focus ul { height: 380px; position: absolute; }
#focus ul li { float: left; width: 726px; height: 280px; overflow: hidden; position: relative; background: #000; }
#focus .preNext { width: 45px; height: 100px; position: absolute; top: 90px; background: url(../images/sprite.png) no-repeat 0 0; cursor: pointer; }
#focus .pre { left: 0; }
#focus .next { right: 0; background-position: right top; }
#focus .btnBg { position: absolute; width: 726px; height: 20px; left: 0; bottom: 0; background: #000; }
#focus .btn { position: absolute; width: 726px; height: 10px; padding: 5px 10px; right: 0; bottom: 0; text-align: right; }
#focus .btn span { display: inline-block; _display: inline; _zoom: 1; width: 25px; height: 10px; _font-size: 0; margin-left: 5px; cursor: pointer; background: #fff; }
#focus .btn span.on { background: #fff; }
<script type="text/javascript">
$(function() {
var sWidth = $("#focus").width(); //获取焦点图的宽度(显示面积)
var len = $("#focus ul li").length; //获取焦点图个数
var index = 0;
var picTimer; //以下代码添加数字按钮和按钮后的半透明条,还有上一页、下一页两个按钮
var btn = "<div class='btnBg'></div><div class='btn'>";
for(var i=0; i < len; i++) {
btn += "<span></span>";
}
btn += "</div><div class='preNext pre'></div><div class='preNext next'></div>";
$("#focus").append(btn);
$("#focus .btnBg").css("opacity",0.5); //为小按钮添加鼠标滑入事件,以显示相应的内容
$("#focus .btn span").css("opacity",0.4).mouseenter(function() {
index = $("#focus .btn span").index(this);
showPics(index);
}).eq(0).trigger("mouseenter"); //上一页、下一页按钮透明度处理
$("#focus .preNext").css("opacity",0.2).hover(function() {
$(this).stop(true,false).animate({"opacity":"0.5"},300);
},function() {
$(this).stop(true,false).animate({"opacity":"0.2"},300);
}); //上一页按钮
$("#focus .pre").click(function() {
index -= 1;
if(index == -1) {index = len - 1;}
showPics(index);
}); //下一页按钮
$("#focus .next").click(function() {
index += 1;
if(index == len) {index = 0;}
showPics(index);
}); //本例为左右滚动,即所有li元素都是在同一排向左浮动,所以这里需要计算出外围ul元素的宽度
$("#focus ul").css("width",sWidth * (len)); //鼠标滑上焦点图时停止自动播放,滑出时开始自动播放
$("#focus").hover(function() {
clearInterval(picTimer);
},function() {
picTimer = setInterval(function() {
showPics(index);
index++;
if(index == len) {index = 0;}
},4000); //此4000代表自动播放的间隔,单位:毫秒
}).trigger("mouseleave"); //显示图片函数,根据接收的index值显示相应的内容
function showPics(index) { //普通切换
var nowLeft = -index*sWidth; //根据index值计算ul元素的left值
$("#focus ul").stop(true,false).animate({"left":nowLeft},300); //通过animate()调整ul元素滚动到计算出的position
//$("#focus .btn span").removeClass("on").eq(index).addClass("on"); //为当前的按钮切换到选中的效果
$("#focus .btn span").stop(true,false).animate({"opacity":"0.4"},300).eq(index).stop(true,false).animate({"opacity":"1"},300); //为当前的按钮切换到选中的效果
}
});</script>
<div id="jiao_dian">
<div class="wrapper">
<div id="focus">
<ul>
<li><a target="_blank" href="#" title="登录""><img src="data:images/jiao_1.png"/></a></li>
<li><a target="_blank" href="#"><img src="data:images/jiao_1.png"/></a></li>
<li><a target="_blank" href="#"><img src="data:images/jiao_1.png"/></a></li>
<li><a target="_blank" href="#"><img src="data:images/jiao_1.png"/></a></li>
<li><a target="_blank" href="#"><img src="data:images/jiao_1.png"/></a></li>
</ul>
<!-- <div class="btnBg" style="opacity: 0.5;"></div><div class="btn"><span style="opacity: 1;"></span><span style="opacity: 0.4;"></span><span style="opacity: 0.4;"></span><span style="opacity: 0.4;"></span><span style="opacity: 0.4;"></span></div><div class="preNext pre" style="opacity: 0.2;"></div><div class="preNext next" style="opacity: 0.2;"></div>
-->
</div>
</div> <div class="an_niu">
<ul>
<li><a href="DistanceEducationWeb/PersonRegister.aspx"><img src="data:images/an_1.png"/></a></li>
<li><a href="/DistanceEducationWeb/UnitRegister.aspx"><img src="data:images/an_2.png"/></a></li>
<li><a href="DistanceEducationWeb/PersonHome.aspx"><img src="data:images/an_3.png"/></a></li>
<li><a href="DistanceEducationWeb/payment.aspx"><img src="data:images/an_4.png"/></a></li>
</ul>
</div>
<div class="clear"></div>
</div>
JQ主页图片划动切换效果的更多相关文章
- 一分钟搞定触手app主页酷炫滑动切换效果
代码地址如下:http://www.demodashi.com/demo/12826.html 前言: 前几天在看手机直播的时候,自己就用上了触手app.一进到主页就看上了里面页面切换的效果,自己想这 ...
- Flexslider图片轮播、文字图片相结合滑动切换效果
Flexslider是一款基于的jQuery内容滚动插件.它能让你轻松的创建内容滚动的效果,具有非常高的可定制性.开发者可以使用Flexslider轻松创建各种图片轮播效果.焦点图效果.图文混排滚动效 ...
- JS框架_(JQuery.js)图片相册掀开切换效果
百度云盘 传送门 密码:y0dk 图片掀开切换效果: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&quo ...
- Flexslider插件实现图片轮播、文字图片相结合滑动切换效果
插件下载: 点击下载 密码: fbeg Flexslider具有以下特性: 支持滑动和淡入淡出效果. 支持水平.垂直方向滑动. 支持键盘方向键控制. 支持触控滑动. 支持图文混排,支持各种html元素 ...
- jq demo—图片翻页展示效果 animate()动画
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- CSS3新增文本属性实现图片点击切换效果
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Jquery实现图片切换效果(IE,FF,Goole)都可以正常运行
这里先对标签的样式进行设置(我这里只用了3张图片,可以根据自己的情况,添加) <style type="text/css"> /*展示图片切换的div样式*/ #Sho ...
- jquery.roundabout.js实现3D图片层叠旋转木马切换
最近项目中需要实现3D图片层叠旋转木马切换的效果,于是用到了jquery.roundabout.js. 兼容性如图: html结构代码: <div id="featured-area& ...
- 精致3D图片切换效果,最适合企业产品展示
这是一个精致的立体图片切换效果,特别适合企业产品展示,可立即用于实际项目中.支持导航和自动播放功能, 基于 CSS3 实现,推荐使用最新的 Chrome,Firefox 和 Safari 浏览器浏览效 ...
随机推荐
- 关于图算法 & 图分析的基础知识概览
网址:https://learning.oreilly.com/library/view/graph-algorithms-/9781492060116/ 你肯定没有读过这本书,因为这本书的发布日期是 ...
- uwsgi Import Error: No module named 'encodings'
https://serverfault.com/questions/558427/uwsgi-import-error-no-module-named-encodings I don't know i ...
- LeetCode——456.132模式
给定一个整数序列:a1, a2, ..., an,一个132模式的子序列 ai, aj, ak 被定义为:当 i < j < k 时,ai < ak < aj.设计一个算法,当 ...
- spring学习之依赖注入DI与控制反转IOC
一 Ioc基础 1.什么是Ioc? Ioc(Inversion of Control)既控制反转,Ioc不是一种技术,而是一种思想,在Java开发中意味着将设计好的对象交给容器来进行控制,并不是像传统 ...
- Error:Execution failed for task ':app:preDebugAndroidTestBuild'. > Conflict with dependency
Error : Execution failed for task ’ :app: preDebugAndroidTestBuild’.Conflict with dependency ‘com.an ...
- 面向对象 part3 构造函数 原型函数
6.2创建对象 方法:对象字面量 object构造函数 缺点:都是创建单个对象.同一个接口创建多个对象,会产生大量重复代码 6.2.1工厂模式 用函数封装以特定的接口创建对象 function cr ...
- fread 和fgets 函数的使用
两个函数都是对FILE *fp 文件进行读取信息,fgets是每次读取一行,fread是一下子读完所有的文件内容. //一.fread的使用 FILE *fp; int nread; ] fp = f ...
- 关于富文本字段问题(mysql)
1.表字段字符集建议使用: utf8mb4.utf8mb4_general_ci 2.保险起见spring-boot配置: spring:datasource:connection-init-sqls ...
- socker通信-struct模块-粘包问题
Socket概念 Socket是应用层与TCP/IP协议族通信的中间软件抽象层,它是一组接口.在设计模式中,Socket其实就是一个门面模式,它把复杂的TCP/IP协议族隐藏在Socket接口后面,对 ...
- AI大火之下智能手机行业能适应这一风口吗?
今年智能手机行业的变化,实在是让人摸不到头脑.一方面是智能手机厂商依然在拿出各种具有噱头的产品,仿佛整个市场还依然热火朝天.但在另一方面,智能手机出货量却出现大幅下滑.据中国信息通信研究院发布的数据显 ...