网站首页
技术文章
客户案例
联系方式
信息搜索
深山工作室
>
div+css黑色焦点图(幻灯片效果非常 不错)
以下为详细代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <base href="http://hi.baidu.com/koen_li"> <title>黑色风格的JS焦点图</title> <style type="text/css"> *{margin:0;padding:0;border:0;list-style:none;} body{padding:20px;background:#eee;} #myfocus{width:450px;height:296px;overflow:hidden;padding:6px 6px 24px;background:#333 url(http://pigimg.zhongso.com/space/gallery/infoimgs/gc/gcqzj/20100511/2010051111200423950.jpg) no-repeat;position:relative;} #myfocus #myloading{position:absolute;top:0;left:0;z-index:9999;width:462px;height:326px;background:#333;color:#f60;font-size:12px;text-align:center;padding-top:90px;} #myfocus #myloading .bg{position:absolute;top:0;left:0;z-index:-1;}/*载入画面*/ #myfocus .pics{width:450px;height:296px;overflow:hidden;position:relative;} #myfocus .pics ul{height:296px;position:absolute;} #myfocus .pics ul li{width:450px;height:296px;float:left;position:relative;}/*图片大小450px*296px*/ #myfocus .pics ul li div,#myfocus .pics ul li div span,#myfocus .pics ul li div a{display:block;position:absolute;bottom:0;left:0;width:100%;height:34px;} #myfocus .pics ul li div span{filter:alpha(opacity=50);opacity: 0.5;background:#000;}/*文字标题的背景样式*/ #myfocus .pics ul li div a{line-height:34px;overflow:hidden;padding-left:16px;text-decoration:none;font-size:14px;color:#fff;font-weight:bold;}/*文字标题样式*/ #myfocus .mybtn{position:absolute;bottom:8px;right:8px;} #myfocus .mybtn ul li{float:left;width:16px;height:6px;margin-left:4px;overflow:hidden;border:1px solid #000;background:#ccc;cursor:pointer;} #myfocus .mybtn ul li.current{background:#f60;} </style> <script type="text/javascript"> /*design by koen @ 10nian5yue11ri*/ /*http://hi.baidu.com/koen_li*/ function setFocus(ID,t){//主函数... function $(id) {return document.getElementById(id);} function $$(tag,obj){return (typeof obj=='object'?obj:$(obj)).getElementsByTagName(tag);} var n='';//标记 function showPics(num){ if(n===num) return true; if(n==='') n=0; else n=num; var pics=$$('ul',ID)[0]; var tit=$$('div',pics)[num]; if (!pics.style.left){pics.style.left = 0+'px';} if (!tit.style.bottom||parseInt(tit.style.bottom)>-34){tit.style.bottom = -34+'px';} var endX=-num*$$('div',ID)[0].clientWidth; var goimg=function(){ X=parseInt(pics.style.left); if (pics.movement){clearTimeout(pics.movement);} if(parseInt(pics.style.left)==endX) return true; if((endX-X)>0) X+=Math.ceil((endX-X) / 10); else X+=Math.floor((endX-X) / 10); pics.style.left=X+'px'; pics.movement = setTimeout(goimg, 5); } var gotit=function(){ var y=parseInt(tit.style.bottom); if (tit.movement){clearTimeout(tit.movement);} if(y==0) return true; y+=Math.ceil((0-y) / 10); if(parseInt(pics.style.left)==endX) tit.style.bottom=y+'px'; if(y<0) tit.movement = setTimeout(gotit, 16); } goimg(); gotit(); } function classNormal() {//数字标签样式清除 var focusBtnList = $$('li',$$('ul',ID)[1]); for (var i = 0; i < focusBtnList.length; i++) { focusBtnList[i].className = ''; } } function focusChange() {//交互切换 var focusBtnList = $$('li',$$('ul',ID)[1]); for (var i = 0; i < focusBtnList.length; i++) { focusBtnList[i].I=i; focusBtnList[i].onmouseover = function(){ showPics(this.I); classNormal(); focusBtnList[this.I].className = 'current'; } } } var autoFocusChange=function() {//自动运行 if (atuokey) return; var focusBtnList = $$('li',$$('ul',ID)[1]); for (var i = 0; i < focusBtnList.length; i++) { if (focusBtnList[i].className == 'current') { var currentNum = i; } } if(currentNum<focusBtnList.length-1){ showPics(currentNum+1); classNormal(); focusBtnList[currentNum+1].className = 'current'; }else if(currentNum==focusBtnList.length-1){ showPics(0); classNormal(); focusBtnList[0].className = 'current'; } } var atuokey = ''; function init(){//初始化<div><span></span><a href="#">文字说明</a></div> var ul=$$('ul',ID)[0]; var li=$$('li',ul); var NUM=li.length; var wid=$('myloading')?$$('div',ID)[1].clientWidth:$$('div',ID)[0].clientWidth;ul.style.width=wid*NUM+'px'; for(var i=0;i<NUM;i++){ var a=li[i].getElementsByTagName('a')[0]; var img=li[i].getElementsByTagName('img')[0]; li[i].innerHTML=li[i].innerHTML+'<div><span></span><a href="'+a+'">'+img.alt+'</a></div>'; } var s='<div class="mybtn"><ul>'; for(var i=0;i<NUM;i++){s+='<li></li>'} s+='</ul></div>'; $(ID).innerHTML+=s; $(ID).removeChild($('myloading')); showPics(0); classNormal(); $$('li',$$('ul',ID)[1])[0].className = 'current'; $(ID).onmouseover = function() { atuokey = true; clearInterval(auto); } $(ID).onmouseout = function() { atuokey = false; auto=setInterval(autoFocusChange, T); } } var T=t*1000;//每帧图片停留的时间,1000=1秒 var auto=''; init(); focusChange(); auto=setInterval(autoFocusChange, T); }; window.onload=function(){ setFocus('myfocus',4); } </script> </head> <body> <div id="myfocus"><!--只需定义这个ID即可--> <div id="myloading">请稍候...<br /><br /><img src="http://pigimg.zhongso.com/space/gallery/infoimgs/gc/gcqzj/20100510/2010051020541820883.gif" /><img class="bg" src="http://pigimg.zhongso.com/space/gallery/infoimgs/gc/gcqzj/20100511/2010051111200423950.jpg" /></div><!--载入画面,可以不要--> <div class="pics"> <ul> <li><a href="#"><img src="http://pigimg.zhongso.com/space/gallery/infoimgs/gc/gcqzj/20100510/2010051018042735524.jpg" alt="图片1来源于网络,版权属于作者" /></a></li> <li><a href="#"><img src="http://pigimg.zhongso.com/space/gallery/infoimgs/gc/gcqzj/20100510/2010051018044355191.jpg" alt="图片2来源于网络,版权属于作者" /></a></li> <li><a href="#"><img src="http://pigimg.zhongso.com/space/gallery/infoimgs/gc/gcqzj/20100510/2010051018050315609.jpg" alt="图片3来源于网络,版权属于作者" /></a></li> <li><a href="#"><img src="http://pigimg.zhongso.com/space/gallery/infoimgs/gc/gcqzj/20100510/2010051018052886494.jpg" alt="图片4来源于网络,版权属于作者" /></a></li> <li><a href="#"><img src="http://pigimg.zhongso.com/space/gallery/infoimgs/gc/gcqzj/20100510/2010051018055365260.jpg" alt="图片5来源于网络,版权属于作者" /></a></li> <li><a href="#"><img src="http://pigimg.zhongso.com/space/gallery/infoimgs/gc/gcqzj/20100510/2010051018061333534.jpg" alt="图片6来源于网络,版权属于作者" /></a></li> </ul> </div> </div> </body> </html>
以下为详细代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <base href="http://hi.baidu.com/koen_li"> <title>黑色风格的JS焦点图</title> <style type="text/css"> *{margin:0;padding:0;border:0;list-style:none;} body{padding:20px;background:#eee;} #myfocus{width:450px;height:296px;overflow:hidden;padding:6px;border:1px solid #333;font:12px Verdana, Arial, Helvetica, sans-serif;background:#000 url(http://pigimg.zhongso.com/space/gallery/infoimgs/gc/gcqzj/20100511/2010051111200423950.jpg) no-repeat;position:relative;} #myfocus #myloading{position:absolute;top:0;left:0;z-index:9999;width:462px;height:326px;background:#333;color:#f60;font-size:12px;text-align:center;padding-top:90px;} #myfocus #myloading .bg{position:absolute;top:0;left:0;z-index:-1;}/*载入画面*/ #myfocus .pics{width:450px;height:296px;overflow:hidden;position:relative;} #myfocus .pics ul{height:296px;position:absolute;} #myfocus .pics ul li{width:450px;height:296px;float:left;position:relative;}/*图片大小450px*296px*/ #myfocus .pics ul li div,#myfocus .pics ul li div span,#myfocus .pics ul li div a{display:block;position:absolute;bottom:0;left:0;width:100%;height:34px;} #myfocus .pics ul li div span{filter:alpha(opacity=50);opacity: 0.5;background:#000;}/*文字标题的背景样式*/ #myfocus .pics ul li div a{line-height:34px;overflow:hidden;padding-left:16px;text-decoration:none;font-size:14px;color:#fff;font-weight:bold;}/*文字标题样式*/ #myfocus .mybtn{position:absolute;bottom:10px;right:12px;} #myfocus .mybtn ul li{text-align:center;float:left;width:18px;height:16px;line-height:16px;margin-left:4px;overflow:hidden;border:1px solid #000;background:#ccc;cursor:pointer;} #myfocus .mybtn ul li.current{background:#f60;color:#fff;} </style> <script type="text/javascript"> /*design by koen @ 10nian5yue11ri*/ /*http://hi.baidu.com/koen_li*/ function setFocus(ID,t){//主函数... function $(id) {return document.getElementById(id);} function $$(tag,obj){return (typeof obj=='object'?obj:$(obj)).getElementsByTagName(tag);} var n='';//标记 function showPics(num){ if(n===num) return true; if(n==='') n=0; else n=num; var pics=$$('ul',ID)[0]; var tit=$$('div',pics)[num]; if (!pics.style.left){pics.style.left = 0+'px';} if (!tit.style.bottom||parseInt(tit.style.bottom)>-34){tit.style.bottom = -34+'px';} var endX=-num*$$('div',ID)[0].clientWidth; var goimg=function(){ X=parseInt(pics.style.left); if (pics.movement){clearTimeout(pics.movement);} if(parseInt(pics.style.left)==endX) return true; if((endX-X)>0) X+=Math.ceil((endX-X) / 10); else X+=Math.floor((endX-X) / 10); pics.style.left=X+'px'; pics.movement = setTimeout(goimg, 5); } var gotit=function(){ var y=parseInt(tit.style.bottom); if (tit.movement){clearTimeout(tit.movement);} if(y==0) return true; y+=Math.ceil((0-y) / 10); if(parseInt(pics.style.left)==endX) tit.style.bottom=y+'px'; if(y<0) tit.movement = setTimeout(gotit, 16); } goimg(); gotit(); } function classNormal() {//数字标签样式清除 var focusBtnList = $$('li',$$('ul',ID)[1]); for (var i = 0; i < focusBtnList.length; i++) { focusBtnList[i].className = ''; } } function focusChange() {//交互切换 var focusBtnList = $$('li',$$('ul',ID)[1]); for (var i = 0; i < focusBtnList.length; i++) { focusBtnList[i].I=i; focusBtnList[i].onmouseover = function(){ showPics(this.I); classNormal(); focusBtnList[this.I].className = 'current'; } } } var autoFocusChange=function() {//自动运行 if (atuokey) return; var focusBtnList = $$('li',$$('ul',ID)[1]); for (var i = 0; i < focusBtnList.length; i++) { if (focusBtnList[i].className == 'current') { var currentNum = i; } } if(currentNum<focusBtnList.length-1){ showPics(currentNum+1); classNormal(); focusBtnList[currentNum+1].className = 'current'; }else if(currentNum==focusBtnList.length-1){ showPics(0); classNormal(); focusBtnList[0].className = 'current'; } } var atuokey = ''; function init(){//初始化<div><span></span><a href="#">文字说明</a></div> var ul=$$('ul',ID)[0]; var li=$$('li',ul); var NUM=li.length; var wid=$('myloading')?$$('div',ID)[1].clientWidth:$$('div',ID)[0].clientWidth;ul.style.width=wid*NUM+'px'; for(var i=0;i<NUM;i++){ var a=li[i].getElementsByTagName('a')[0]; var img=li[i].getElementsByTagName('img')[0]; li[i].innerHTML=li[i].innerHTML+'<div><span></span><a href="'+a+'">'+img.alt+'</a></div>'; } var s='<div class="mybtn"><ul>'; for(var i=0;i<NUM;i++){s+='<li>'+(i+1)+'</li>'} s+='</ul></div>'; $(ID).innerHTML+=s; $(ID).removeChild($('myloading')); showPics(0); classNormal(); $$('li',$$('ul',ID)[1])[0].className = 'current'; $(ID).onmouseover = function() { atuokey = true; clearInterval(auto); } $(ID).onmouseout = function() { atuokey = false; auto=setInterval(autoFocusChange, T); } } var T=t*1000;//每帧图片停留的时间,1000=1秒 var auto=''; init(); focusChange(); auto=setInterval(autoFocusChange, T); }; window.onload=function(){ setFocus('myfocus',4); } </script> </head> <body> <div id="myfocus"><!--只需定义这个ID即可--> <div id="myloading">请稍候...<br /><br /><img src="http://pigimg.zhongso.com/space/gallery/infoimgs/gc/gcqzj/20100510/2010051020541820883.gif" /><img class="bg" src="http://pigimg.zhongso.com/space/gallery/infoimgs/gc/gcqzj/20100511/2010051111200423950.jpg" /></div><!--载入画面,可以不要--> <div class="pics"> <ul> <li><a href="#"><img src="http://pigimg.zhongso.com/space/gallery/infoimgs/gc/gcqzj/20100510/2010051018042735524.jpg" alt="图片1来源于网络,版权属于作者" /></a></li> <li><a href="#"><img src="http://pigimg.zhongso.com/space/gallery/infoimgs/gc/gcqzj/20100510/2010051018044355191.jpg" alt="图片2来源于网络,版权属于作者" /></a></li> <li><a href="#"><img src="http://pigimg.zhongso.com/space/gallery/infoimgs/gc/gcqzj/20100510/2010051018050315609.jpg" alt="图片3来源于网络,版权属于作者" /></a></li> <li><a href="#"><img src="http://pigimg.zhongso.com/space/gallery/infoimgs/gc/gcqzj/20100510/2010051018052886494.jpg" alt="图片4来源于网络,版权属于作者" /></a></li> <li><a href="#"><img src="http://pigimg.zhongso.com/space/gallery/infoimgs/gc/gcqzj/20100510/2010051018055365260.jpg" alt="图片5来源于网络,版权属于作者" /></a></li> <li><a href="#"><img src="http://pigimg.zhongso.com/space/gallery/infoimgs/gc/gcqzj/20100510/2010051018061333534.jpg" alt="图片6来源于网络,版权属于作者" /></a></li> </ul> </div> </div> </body> </html>
前一页:
javascript实现图片预览功能
后一页:
没有了
相关阅读
javascript 表单(文本框)触发鼠标事件大全
div+css黑色焦点图(幻灯片效果非常 不错)
判断用户注册密码强度的JS代码
超级实用且不花哨的js代码大全( 6 )
超级实用且不花哨的js代码大全( 1 )
html表单里面的label详细
网站策划:网站栏目和页面的策划
移动层,并且保存各个层的位置,可以方便的制作成为一个动态的页面
更多>>
图形特效相关信息
div+css黑色焦点图(幻灯片效果非常 不错)
javascript实现图片预览功能
比较实用的利用javascript按比例相应缩放图片大小
一个效果非常不错图片载入loading等待效果
利用css实现图片选中后显示文字与图片效果
更多>>
最新添加
dw里面查找替换使用正则删除sqlserver里面的CONSTRAINT
Android移动端自动化测试:使用UIAutomatorViewer与Selenium定位元素
抖音直播音挂载小雪花 懂车帝小程序
javascript获取浏览器指纹可以用来做投票
火狐Mozilla Firefox出现:无法载入您的Firefox配置文件 它可能已经丢失 或是无法访问 问题解决集合处理办法
百度小程序开发
HTML
微信小程序开发
微信公众号开发
uni-app
asp函数库
ASP
下载类信息
DIV+CSS
个人空间
代码生成
SEO搜索引擎忧化
asp.net
电商
python
页面特效
表格特效
导航菜单
图形特效
表单特效
时间日期
色彩类别
链接特效
网页特效
系统硬件
网站公告
网页学习
技术类文章
网站类信息
旅行社网站案例
旅行社微信案例
头条抖音小程序案例
百度小程序案例
微信小程序案例
小程序案例
旅行社网站案例
投票案例
企业网站建设案例
Copyright ©
深山工作室
All Rights Reserved
服务QQ:
565449214
手机:
13961347334
ICP备案:
苏ICP备15019627号
苏公网安备 32070502010230号
网站首页
业务范围
服务案例
投票系统
联系方式
电话联系