仿拉勾网首页穿墙广告效果

<!doctype html>

<html>

<head>

<meta charset="UTF-8">

<title>Title</title>

<style>

*{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;}

</style>

<script>

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)/90)%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<aLi.length;i++){

through(aLi[i]);

}

};

</script>

</head>

<body>

<ul>

<li><span></span></li>

<li><span></span></li>

<li><span></span></li>

<li><span></span></li>

<li><span></span></li>

<li><span></span></li>

</ul>

</body>

</html>

学习交流平台,群内大神云集,为你指点任何前端的疑难杂症:群号598291783

时间: 2024-08-26 04:34:33

仿拉勾网首页穿墙广告效果的相关文章

CSS3中实现首页穿墙广告效果

㈠分享一组很有趣的代码: 具体如下: <!doctype html> <html> <head> <meta charset="UTF-8"> <title>穿墙广告</title> <style> *{ margin:0; padding:0; list-style:none; } ul{ overflow:hidden; width:630px; margin:100px auto; } ul li

仿百度首页选项卡切换效果

效果:http://hovertree.com/texiao/jquery/71/ 代码如下: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jQuery仿百度首页选项卡切换效果 - 何问起</title> <base ta

仿支付宝首页头部伸缩效果

原文链接:https://mp.weixin.qq.com/s/GegMt7GDBCFVoUgFQWG3Sw 每次打开支付宝首页滑动,头部的伸缩动画甚是吸引人.于是自己决定动手来实现一个. 无图言虚空,效果图: 首先看到这种效果,第一反应就是coordinatorLayout布局,android studio新建项目时,可以直接新建个Scrolling Activity来查看demo效果. 官方自带的布局示例: gradle关联 implementation 'com.android.suppo

安卓首页图片轮播效果(淘宝、京东首页广告效果)

直奔主题: 1.主要原理就是利用定时任务器定时切换ViewPager的页面. 2.里面用了一个读取网络图片的插件.做client使用本地图片轮播的也非常少. 先上个效果图: 项目代码结构截图: 自己定义View 的布局文件layout_slideshow.xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.and

首页大屏广告效果 jquery轮播图淡入淡出

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>jQuery个性化图片轮播效果</title> <script src="js/jquery.js" type="text/javascript"></script> <link rel=

我们这里有仿百度联盟对联广告实现代码

仿百度联盟对联广告源代码展示,主要使用现代浏览器都支持的position:fixed属性,并专门针对ie6做了最大限度的兼容性处理 <style type="text/css"> 02 *{margin:0;padding:0;} 03 body{height:2000px;} 04 .floatAd{width:124px;height:299px; text-align:center; position:fixed;margin-left:0;top:109px; _p

CSS3实战开发:仿天猫首页图片展示动画特效实战开发

各位网友大家好,我是陌上花会开,人称陌陌.今天我带领大家开发一个仿天猫首页图片展示动画特效的案例.一如往常,我既不提供源码给大家,也不提供Demo给大家,只是希望大家能跟着我的讲解,然后将代码一步步复制到本地,本人可以保证,页面上的代码复制到本地,绝对百分百运行,且得到与陌陌一样的运行效果.我这么做只为激起大伙的动手能力,望大家能明白我的用心. 好了,不废话了,直接本篇的实战开发吧. 我们看一下我们今天要做的实战案例效果图: 1. 鼠标划过前: 2. 鼠标划过右侧的图片时: 可能大伙看这个静态截

jquery实现可展开收缩的首页大图广告展示方式 泰山压顶代码js V1.0

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="

广告效果监测

广告效果监测 广告效果监测是指通过付费广告,客户点击进入网站接下来的一系列活动 广告投放前.投放中.投放后的效果实施监测和评估,并不是个孤立的过程,需要把监测到数据进行一个整理,并建立一个系统的数据库,不仅会对本次广告进行一 个系统的评估,同时它的评估结果将会被录入到历史投放效果中,对下次的广告投放起到一个很好的借鉴和参考,并对今后企业广告往更好的方向发展起到了一个很 好引领作用. 广告投放后的分析就可以对广告效果做一个全面的评估,我们可以从投放后的 分析中可以了解到本次广告投放的ROI怎样.本