JS实现图片高斯模糊切换效果的焦点图实例

焦点图相信对大家来说都不陌生,本文给大家分享的是一种图片高斯模糊切换效果的焦点图,下面话不多说了,来看看实现的效果图和实例代码吧。

效果图

JS实现图片高斯模糊切换效果的焦点图实例

实例代码

<!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> <style> @-webkit-keyframes show { 0%{ opacity:1; -webkit-transform:scale(1); } 100% { opacity:.1; -webkit-transform:scale(3); } } body{ background:#e8d0ca;} #wrap{width:600px; margin:100px auto;border:2px solid #000; position:relative;} #list{ position:relative; height:310px;margin:0;padding:0; list-style:none;} #list li{ width:281px;height:310px; background:url() no-repeat; position:absolute;top:0; transition:.6s;} #list span{ width:100%;height:100%; display:block;transition:.6s;} #list li:nth-of-type(1){ left:0;z-index:1; -webkit-transform:scale(0.8);opacity:0.6;} #list li:nth-of-type(1) span{ background:url(); opacity:1;} #list li:nth-of-type(2){ left:calc(50% - 140px);background-image:url();z-index:2; opacity:1;} #list li:nth-of-type(2) span{ background:url(); opacity:0;} #list li:nth-of-type(3){ left:calc(100% - 281px);background-image:url();z-index:1;-webkit-transform:scale(0.8); opacity:0.6;} #list li:nth-of-type(3) span{ background:url(); opacity:1;} .btn{width:18px;height:29px; position:absolute;top:130px;z-index:10; cursor:pointer;} .btn span{ position:absolute;left:0;top:0; background:inherit; width:100%;height:100%; transition:.5s;} .btn:hover span:nth-of-type(1){-webkit-animation:show 2s infinite; } .btn:hover span:nth-of-type(2){-webkit-animation:show 2s 1s infinite; } #prev{ left:80px; background:url() no-repeat;} #next{ right:80px; background:url() no-repeat;} </style> </head> <body> <div> <ul> <li> <span></span> </li> <li> <span></span> </li> <li> <span></span> </li> </ul> <div> <span></span> <span></span> </div> <div> <span></span> <span></span> </div> </div> <script> window.onload=function() { var oList=document.getElementById("list"); var aLi=oList.children; var oPrev=document.getElementById("prev"); var oNext=document.getElementById("next"); var arr=[]; //arr.unshift(arr.pop());把最后一个删除添加到数组第一个 //arr.push(arr.shift());把第一个删除添加到数组第一个 //获取li的信息 for(var i=0;i<aLi.length;i++) { var oSpan=aLi[i].children[0]; arr[i]={left:getStyle(aLi[i],"left"),opacity:getStyle(aLi[i],"opacity"),scale:getStyle(aLi[i],"-webkit-transform"),zIndex:getStyle(aLi[i],"z-index"),alpha:getStyle(oSpan,"opacity")}; } oPrev.onclick=function() { arr.unshift(arr.pop()); toStyle(); }; oNext.onclick=function() { arr.push(arr.shift()); toStyle(); }; function toStyle() { for(var i=0;i<aLi.length;i++) { var oSpan=aLi[i].children[0]; aLi[i].style.left=arr[i].left; aLi[i].style.opacity=arr[i].opacity; aLi[i].style.WebkitTransform=arr[i].scale; aLi[i].style.zIndex=arr[i].zIndex; oSpan.style.opacity=arr[i].alpha; } } }; function getStyle(obj,attr) { if( obj.currentStyle){ return obj.currentStyle[attr]; } return getComputedStyle(obj)[attr]; } </script> </body> </html>

更多关于JavaScript相关内容感兴趣的读者可查看本站专题:《JavaScript切换特效与技巧总结》、《JavaScript查找算法技巧总结》、《JavaScript动画特效与技巧汇总》、《JavaScript错误与调试技巧总结》、《JavaScript数据结构与算法技巧总结》、《JavaScript遍历算法与技巧总结》及《JavaScript数学运算用法总结

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwdwfy.html