很不错的js幻灯片代码分享
2019独角兽企业重金招聘Python工程师标准>>>
js代码
<script type="text/javascript">
window.onload=function()
{ var dealy=5000; //3秒滾動一张圖片,可自行修改 var MyBox=document.getElementById('mF_ysw_wrap'); var word=document.getElementById('wenzi'); var txt=document.getElementById('txt').getElementsByTagName('li');; var oBox=document.getElementById('box'); var aList=document.getElementById('list'); var aNum=document.getElementById('num').getElementsByTagName('li'); var timer=null; var now=0; for (var i=0; i<aNum.length; i++) { aNum[i].index=i; aNum[i].onmouseover=function() { now=this.index; play(Running); } } function play(fn) { for (var i=0; i<aNum.length; i++) { aNum[i].className=''; } aNum[now].className='active'; fn(aList,{top:-331*now}); } function auto() { clearInterval(timer); timer=setInterval(function() { now++; if(now==aNum.length) { now=0; } play(Flexing); }, dealy); } auto(); MyBox.onmouseover=function() { clearInterval(timer); } MyBox.onmouseout=function() { auto(); }
}
</script>
主要处理函数
function getStyle(obj,name)
{if(obj.currentStyle){return obj.currentStyle[name];}else{return getComputedStyle(obj,false)[name];}
}function Running(obj,json,fnEnd)
{clearInterval(obj.timer);obj.timer=setInterval(function(){var now=0;var bStop=true;for (var attr in json){if(attr=='opacity'){now=Math.round(parseFloat(getStyle(obj,attr))*100);}else{now=parseInt(getStyle(obj,attr));document.getElementById('wenzi').value=attr;}var speed=(json[attr]-now)/5;speed=speed>0?Math.ceil(speed):Math.floor(speed);if(now!=json[attr])bStop=false;if(attr=='opacity'){obj.style.filter='alpha(opacity:'+now+speed+')';obj.style.opacity=(now+speed)/100;}else{obj.style[attr]=speed+now+'px';}}if(bStop){clearInterval(obj.timer);if(fnEnd)fnEnd();}}, 30);
}function Flexing(obj,json,fnEnd)
{clearInterval(obj.timer);obj.timer=setInterval(function(){var now=0;var bStop=true;for (var attr in json){if(!obj.speed)obj.speed={};if(!obj.speed[attr])obj.speed[attr]=0;now=parseInt(getStyle(obj,attr));if(Math.abs(json[attr]-now)>1 || Math.abs(obj.speed[attr])>1){bStop=false;obj.speed[attr]+=(json[attr]-now)/5;obj.speed[attr]*=0.85;var MaxSpeed=50;if(Math.abs(obj.speed[attr])>MaxSpeed){obj.speed[attr]=obj.speed[attr]>0?MaxSpeed:-MaxSpeed;}obj.style[attr]=now+obj.speed[attr]+'px';}}if(bStop){clearInterval(obj.timer);obj.style[attr]=json[attr]+'px';if(fnEnd)fnEnd();}}, 30);
}
body部分内容
<input type="text" id="wenzi" value="">
<div class="mF_ysw_wrap" id="mF_ysw_wrap">
<div id="myFocus" class=" mF_ysw mF_ysw_myFocus">
<div class="slider">
<div class="pic" id="box"> <ul id="list" style="width:679px; top:0px;position:absolute;">
<li style="width: 679px;"><a href="#"><img width="679" height="331" src="img/1.jpg" thumb="" alt="酷站代码整理" text="图片1更详细的描述文字"></a></li>
<li style="width: 679px;"><a href="#"><img width="679" height="331" src="img/2.jpg" thumb="" alt="酷站代码整理" text="图片2更详细的描述文字"></a></li>
<li style="width: 679px;"><a href="#"><img width="679" height="331" src="img/3.jpg" thumb="" alt="酷站代码整理" text="图片3更详细的描述文字"></a></li>
<li style="width: 679px;"><a href="#"><img width="679" height="331" src="img/4.jpg" thumb="" alt="酷站代码整理" text="图片4更详细的描述文字"></a></li>
<li style="width: 679px;"><a href="#"><img width="679" height="331" src="img/5.jpg" thumb="" alt="酷站代码整理" text="图片5更详细的描述文字"></a></li> </ul>
</div>
<div class="txt" id="txt">
<ul> <li style="top: 0px;"><a href="#">酷站代码整理</a><p>图片1更详细的描述文字</p><b></b></li> <li style="top: 0px;"><a href="#">酷站代码整理</a><p>图片2更详细的描述文字</p><b></b></li> <li style="top: 0px;"><a href="#">酷站代码整理</a><p>图片3更详细的描述文字</p><b></b></li> <li style="top: 0px;"><a href="#">酷站代码整理</a><p>图片4更详细的描述文字</p><b></b></li> <li style="top: 0px;"><a href="#">酷站代码整理</a><p>图片5更详细的描述文字</p><b></b></li>
</ul>
</div>
</div>
</div>
<div class="num" id="num">
<ul> <li class="active"><img src="img/1.jpg" width="80" height="50"><a>图片1更详细的描述文字</a><b></b></li> <li><img src="img/2.jpg" width="80" height="50"><a>图片2更详细的描述文字</a><b></b></li> <li><img src="img/3.jpg" width="80" height="50"><a>图片3更详细的描述文字</a><b></b></li> <li><img src="img/4.jpg" width="80" height="50"><a>图片4更详细的描述文字</a><b></b></li> <li><img src="img/5.jpg" width="80" height="50"><a>图片5更详细的描述文字</a><b></b></li>
</ul>
</div>
</div>
样式
<style type="text/css">
body { background:#fff; padding:20px;}
.mF_ysw_wrap{position: relative;float: left;overflow: hidden;padding: 6px;border: 1px solid #333;width:946px;height:331px;}
#myFocus {width: 679px;height: 331px;clear: both;}
.mF_ysw_myFocus * {margin: 0;padding: 0;border: 0;list-style: none;}
.mF_ysw_wrap * {margin: 0;padding: 0;border: 0;list-style: none;}
.mF_ysw_myFocus {position: relative;height: 331px;overflow: hidden;font: 12px/1.5 Verdana;text-align: left;background: #fff;visibility: visible!important;}
.mF_ysw .slider {height: 100%;position: absolute;overflow: hidden;}
.mF_ysw .slider .pic {height: 100%;width: 100%;}
.mF_ysw_myFocus .pic {position: relative;height: 331px;overflow: hidden;}
.mF_ysw .slider .pic li {height: 331px;overflow: hidden;float:left;}
.mF_ysw .slider .txt {width: 100%;}
.mF_ysw .slider .txt li {position: relative;height: 34px;line-height: 34px;display:inline-block;}
.mF_ysw_myFocus .txt li {width: 675px;height: 34px !important;}
.mF_ysw .slider .txt li a {position: relative;z-index: 1;color: #fff;font-size: 14px;font-weight: bold;text-decoration:none;}
.mF_ysw .slider .txt li b {width:679px;height: 100%;position: absolute;top: 0;background: #000;filter: alpha(opacity=40);opacity: 0.4;}
.mF_ysw_wrap .num {width:260px;position: absolute;z-index: 2;bottom: 6px;right: 12px;}
.mF_ysw_wrap .num li {width: 260px;height: 60px;line-height: 16px;margin-left: 4px;text-align: center;border: 1px solid #000;cursor: pointer;margin-top:5px;}
.mF_ysw_wrap .num li img{margin-top:5px;position:absolute;left:10px;}
.mF_ysw_wrap .num li a{margin-top:5px;position:absolute;left:100px;font-family:"微软雅黑";font-size:14px;}
.mF_ysw_wrap .num li.active{background:#ff9900;color:white;}
</style>
转载于:https://my.oschina.net/codegong/blog/318495
很不错的js幻灯片代码分享相关推荐
- 很不错的JS+CSS滑动门_网页代码站(www.webdm.cn)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 分享63个JS幻灯片代码,总有一款适合您
分享63个JS幻灯片代码,总有一款适合您 63个JS幻灯片代码下载链接:https://pan.baidu.com/s/1tWjsZD6ZiHGiXYmDOqxqgA?pwd=nwl2 提取码:nw ...
- 分享99个JS幻灯片代码,总有一款适合您
分享99个JS幻灯片代码,总有一款适合您 99个JS幻灯片代码下载链接:https://pan.baidu.com/s/1n8UQ41cem0GmgsOXCq9kMw?pwd=m5zf 提取码:m5 ...
- 很不错的JS+CSS滑动门
代码简介: 绝对值得一看的CSS滑动门,因为它在鼠标放上后自动弹出一个带阴影的层,无操作的情况下层会自动隐藏,这样更节省网页布局,而且它的风格也很清新,淘宝网有这种效果,没有用到任何修饰图片,绝对不容 ...
- html加js倒计时代码,分享最简单的JavaScript倒计时代码(附完整代码)
工作中经常需要在页面中设置倒计时,那你知道JS倒计时代码怎么写吗?这篇文章就给大家分享一个最简单的JS倒计时代码,以及详细的倒计时JS代码的思路,,有一定的参考价值,感兴趣的朋友可以看看. 举例:设定 ...
- 网站首页js幻灯片代码
JS图片幻灯片,网站首页专用的图片特效代码,旅游网站用着最合适了,支持图片说明,每一幅图片都可以加标题和简短的文字介绍,右下角有图片切换控制按钮,示例中仅有5张图片,不过在实际应用中,你可以添加更多的 ...
- html实现文字隐藏展开特效代码,外贸建站之隐藏展开文字JS特效代码分享
在很多网站我们都看到有文字隐藏展开的特效,这里我们分享一个文字隐藏展开的JS代码.(function(){ var o = document.getElementById("hutia&qu ...
- js简单代码分享到QQ空间、新浪微博
分享到QQ空间: function qqkj(title){var p = { url:location.href, showcount:'1',/*是否显示分享总数,显示:'1',不显示:'0' * ...
- 分享78个JS相册代码,总有一款适合您
分享78个JS相册代码,总有一款适合您 78个JS相册代码下载链接:https://pan.baidu.com/s/1rV_Mk-AF-bCLgwIccvrmAQ?pwd=y4el 提取码:y4el ...
- 分享116个JS图片代码,总有一款适合您
分享116个JS图片代码,总有一款适合您 116个JS图片代码下载链接:https://pan.baidu.com/s/1ebJsZ5s3GAhetqfJiA1ohg?pwd=e973 提取码:e9 ...
最新文章
- 经典密码学——行置换加密法
- 80x86汇编按二进制输出数字的程序图解和代码解释
- 作者:陈康(1976-),男,博士,清华大学计算机科学与技术系、深圳清华大学研究院、浙江清华长三角研究院鄞州创新中心副教授...
- convolutional pose machines
- C# 类和结构的成员
- fireworks html制作,fireworks怎么制作网页
- HDFS遍历子目录 Hadoop fs -ls -R path
- linux限制message日志大小,message显示rsyslog日志服务警告信息due to rate-limiting
- 视频教程-ps基础课程绝对初级,小白听得懂-Photoshop
- android 应用软件注册与自动登录代码
- mixly 添加micropython_Mixly For Mac
- Win 10系统安装3ds max 2014
- Hibernate_day01
- informatica odbc oracle,Informatica数据源配置
- Oracle enq: TX contention 和 enq: TM contention 等待事件说明
- HDU 4997 Biconnected (状态压缩DP)
- 刷新 windows 图标
- 【245期】面试官:同类中两个方法加同步锁,多个线程支持同时访问这两个方法吗?...
- 如何翻译音频?音频翻译器有哪些?
- 实时指令控制继电器(树莓派)
热门文章
- 内部收益率irr_爱心人寿心相随年金险,IRR内部收益率测算
- python 图像刚性变换_Python-OpenCV 19. 图像处理形态学变换
- python学习_Python学习 基础篇完结
- split-lapply-cbind模式--R语言
- rep( )函数--R语言
- 猴子数据让你深刻了解微信富媒体
- IBM主机增加“交易实时分析”新能力
- 《嵌入式 Linux C 语言应用程序设计(修订版)》——2.1 嵌入式Linux下C语言概述...
- MySQL 数据库重装失败最后一步无法启动server的解决办法
- QT5.12界面再win10下总是莫名卡死