JS打造的一款响应鼠标变化很炫的图片特效代码
来源:广州中睿信息技术有限公司官网
发布时间:2012/10/21 23:25:16 编辑:admin 阅读 388
代码简介:非常炫的图片特效,响应鼠标,鼠标经过时显示放大图片。图片获取的远程图片,可能会比较慢,请等待。代码内容:ViewCode<!DOCTYPEHTMLPUBLIC"-//W3C//DTDH

代码简介

非常炫的图片特效,响应鼠标,鼠标经过时显示放大图片。图片获取的远程图片,可能会比较慢,请等待。

代码内容

View Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>JS打造的一款响应鼠标变化很炫的图片特效代码 - www.webdm.cn</title>
<style type="text/css">
html
{
overflow
: hidden;
}
body
{
margin
: 0px;
padding
: 0px;
background
: #222;
position
: absolute;
width
: 100%;
height
: 100%;
}
#screen
{
position
:absolute;
left
: 0%;
top
: 0%;
width
: 100%;
height
: 100%;
background
: #000;
overflow
: hidden;
}
#pan
{
position
: absolute;
height
: 150%;
width
: 150%;
padding
: 5%;
}
#screen .frame
{
position
: relative;
float
: left;
width
: 29%;
height
: 27%;
margin
: 2%;
background
: #000;
overflow
: hidden;
}
#screen .slider
{
position
: absolute;
width
: 100%;
height
: 100%;
background
: #222;
z-index
: 1000;
}
#pan img
{
position
: absolute;
visibility
: hidden;
}
#pan .legend
{
position
: absolute;
bottom
: 0px;
font-size
: 1em;
color
: #FFF;
width
: 2000px;
font-family
: arial;
font-weight
: bold;
}
</style>
<script type="text/javascript">
var xm = 0;
var ym = 0;
sP
= {
cx :
0,
cy :
0,
N :
0,
R : [],
I : [],
C : [],
L : [],
Id :
0,

init :
function ()
{
this.scr = document.getElementById('screen');
this.pan = document.getElementById('pan');
this.div = this.pan.getElementsByTagName('div');
this.scr.onselectstart = function () { return false; }
this.scr.ondrag = function () { return false; }
for (var i = 0, o; o = this.div[i]; i++)
{
if (o.className == 'frame')
{
/* http://www.webdm.cn */
o.l
= document.createElement('div');
o.l.className
= 'legend';
o.appendChild(o.l);
/* ==== create flap ==== */
o.r
= document.createElement('div');
o.r.className
= 'slider';
o.appendChild(o.r);
o.r.x
= 0;
o.r.l
= o.l;
o.r.p
= 0;
o.r.s
= 2;
o.r.m
= false;
o.img
= o.r.img = o.getElementsByTagName('img')[0];
o.r.c
= Math.random() * 100;
o.r.o
= o;
sP.R[sP.N]
= o.r;
sP.I[sP.N]
= o.img.src;
sP.L[sP.N]
= o.title;
o.title
= "";
sP.N
++;
o.r.onmouseover
= function ()
{
if (!this.m && this.img.complete)
{
if (sP.O != this && !this.n)
{
this.x = this.o.offsetWidth;
this.l.innerHTML = sP.L[sP.Id];
this.img.src = sP.I[sP.Id];
this.resize();
this.n = true;
if(++sP.Id >= sP.N)
{
sP.Id
= 0;
for (var i = 0, o; o = sP.R[i]; i++) o.n = false;
}
}
if (sP.O)
{
sP.O.s
= 2;
sP.C.push(sP.O);
}
this.m = true;
sP.O
= this;
sP.Or
= this;
}
}
o.r.resize
= function ()
{
var i = new Image();
i.src
= this
联系我们CONTACT 扫一扫
愿景:成为最专业的软件研发服务领航者
中睿信息技术有限公司 广州•深圳 Tel:020-38931912 务实 Pragmatic
广州:广州市天河区翰景路1号金星大厦18层中睿信息 Fax:020-38931912 专业 Professional
深圳:深圳市福田区车公庙有色金属大厦509~510 Tel:0755-25855012 诚信 Integrity
所有权声明:PMI, PMP, Project Management Professional, PMI-ACP, PMI-PBA和PMBOK是项目管理协会(Project Management Institute, Inc.)的注册标志。
版权所有:广州中睿信息技术有限公司 粤ICP备13082838号-2