本篇内容主要讲解“HTML怎么实现仿拉勾网首页穿墙广告效果”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“HTML怎么实现仿拉勾网首页穿墙广告效果”吧!代码:
*{margin:0; padding:0; list-style:none;}ul{ overflow:hidden; width:630px; margin:100px auto;}ul li{ float:left; position:relative; width:200px; height:200px; background:#ccc; margin:5px; overflow:hidden;}ul li span{ position:absolute; width:100%; height:100%; background:rgba(255,0,0,0.3); left:-200px; top:0;}function getStyle(obj,sName){ return (obj.currentStyle||getComputedStyle(obj,false))[sName];}function move(obj,json,options){ options = options||{}; options.duration = options.duration||700; options.easing = options.easing||’ease-out’; var start = {}; var dis = {}; for(var name in json){ start[name] = parseFloat(getStyle(obj,name)); dis[name] = json[name]-start[name]; } var count = Math.floor(options.duration/30); var n = 0; clearInterval(obj.timer); obj.timer = setInterval(function(){ n++; for(var name in json){ switch(options.easing){ case ‘linear’: var cur = start[name]+dis[name]*n/count; break; case ‘ease-in’: var a = n/count; var cur = start[name]+dis[name]*Math.pow(a,3); break; case ‘ease-out’: var a = 1-n/count; var cur = start[name]+dis[name]*(1-Math.pow(a,3)); break; } if(name==’opacity’){ obj.style.opacity = cur; obj.style.filter = ‘alpha(opacity:’+cur*100+’)’; }else{ obj.style[name] = cur+’px’; } } if(n==count){ clearInterval(obj.timer); options.complete&&options.complete(); } },30);}function a2d(n){ return n*180/Math.PI;}function hoverDir(ev,obj){ var a = ev.clientX-obj.offsetLeft-obj.offsetWidth/2; var b = obj.offsetTop+obj.offsetHeight/2-ev.clientY; return Math.round((a2d(Math.atan2(b,a))+180)/9免费云主机域名0)%4;}function through(obj){ var oS = obj.children[0]; obj.onmouseenter = function(ev){ var oEvent = ev||event; var dir = hoverDir(oEvent,obj); switch(dir){ case 0: //左 oS.style.left = ‘-200px’; oS.style.top = 0; break; case 1: //下 oS.style.left = 0; oS.style.top = ‘200px’; break; case 2: //右 oS.style.left = ‘200px’; oS.style.top = 0; break; case 3: //上 oS.style.left = 0; oS.style.top = ‘-200px’; break; } move(oS,{left:0,top:0}); }; obj.onmouseleave = function(ev){ var oEvent = ev||event; var dir = hoverDir(oEvent,obj); switch(dir){ case 0: move(oS,{left:-200,top:0}); break; case 1: move(oS,{left:0,top:200}); break; case 2: move(oS,{left:200,top:0}); break; case 3: move(oS,{left:0,top:-200}); break; } };}window.onload = function(){ var aLi = document.getElementsByTagName(‘li’); for(var i=0;i through(aLi[i]); }};
到此,相信大家对“HTML怎么实现仿拉勾网首页穿墙广告效果”有了更深的了解,不妨来实际操作一番吧!这里是百云主机网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
小编给大家分享一下便利店小程序开发能给我们带来什么好处,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!一、便利店小程序开发能给我们带来什么? 1、对于商家来说:商家可以增加销售渠道跟销…
免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。