歡迎您來到網頁代碼站!
設為首頁
加入收藏
留 言 板
精品美文
在線手冊
如果您關閉了瀏覽器的javascript,可能導致頁面部分功能無法顯示,請開啟javascript以便正常瀏覽本網頁。網頁代碼站(www.hbsxmp.com)謝謝您的支持!
代碼首頁
菜單導航
表格相關
表單及按鈕
層和布局
計算轉換
游戲娛樂
廣告代碼
圖片特效
瀏覽器相關
日期時間
背景特效
文本鏈接
熱搜:
div
css
推薦
js
菜單
廣告
flash
TAB
時間
焦點圖
布局
按鈕
您的當前位置:
網頁代碼站
>>
圖片特效
>> 【薦】超絢的JavaScript立體圖片展示代碼
【薦】超絢的JavaScript立體圖片展示代碼
分類:
圖片特效
時間:2009-10-03 點擊:
關鍵詞:
JS
|
css
|
立體圖片
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>【薦】超絢的JavaScript立體圖片展示代碼 - www.hbsxmp.com</title> <style type="text/css"> html { overflow: hidden; } body { position: absolute; margin: 0px; padding: 0px; background: #fff; width: 100%; height: 100%; } #screen { position: absolute; left: 10%; top: 10%; width: 80%; height: 80%; background: #fff; } #screen img { position: absolute; cursor: pointer; width: 0px; height: 0px; -ms-interpolation-mode:nearest-neighbor; } #bankImages { visibility: hidden; } #FPS { position: absolute; right: 5px; bottom: 5px; font-size: 10px; color: #666; font-family: verdana; } </style> <script type="text/javascript"> var Library = {}; Library.ease = function () { this.target = 0; this.position = 0; this.move = function (target, speed) { this.position += (target - this.position) * speed; } } var tv = { O : [], fps : 0, screen : {}, angle : { x : new Library.ease(), y : new Library.ease() }, camera : { x : new Library.ease(), y : new Library.ease() }, create3DHTML : function (i, x, y, z, sw, sh) { var o = document.createElement('img'); o.src = i.src; tv.screen.obj.appendChild(o); o.point3D = { x : x, y : y, z : new Library.ease(), sw : sw, sh : sh, w : i.width, h : i.height }; o.point3D.z.target = z; o.point2D = {}; tv.O.push(o); o.onmouseover = function () { if (this != tv.o) { this.point3D.z.target = tv.mouseZ; tv.camera.x.target = this.point3D.x; tv.camera.y.target = this.point3D.y; if (tv.o) tv.o.point3D.z.target = 0; tv.o = this; } return false; } o.onmousedown = function () { if (this == tv.o) { if (this.point3D.z.target == tv.mouseZ) this.point3D.z.target = 0; else { tv.o = false; this.onmouseover(); } } } o.animate = function () { var x = this.point3D.x - tv.camera.x.position; var y = this.point3D.y - tv.camera.y.position; this.point3D.z.move(this.point3D.z.target, this.point3D.z.target ? .15 : .08); var xy = tv.angle.cx * y - tv.angle.sx * this.point3D.z.position; var xz = tv.angle.sx * y + tv.angle.cx * this.point3D.z.position; var yz = tv.angle.cy * xz - tv.angle.sy * x; var yx = tv.angle.sy * xz + tv.angle.cy * x; var scale = tv.camera.focalLength / (tv.camera.focalLength + yz); x = yx * scale; y = xy * scale; var w = Math.round(Math.max(0, this.point3D.w * scale * this.point3D.sw)); var h = Math.round(Math.max(0, this.point3D.h * scale * this.point3D.sh)); var o = this.style; o.left = Math.round(x + tv.screen.w - w * .5) + 'px'; o.top = Math.round(y + tv.screen.h - h * .5) + 'px'; o.width = w + 'px'; o.height = h + 'px'; o.zIndex = 10000 + Math.round(scale * 1000); } }, /* ==== http://www.hbsxmp.com ==== */ init : function (structure, FL, mouseZ, rx, ry) { this.screen.obj = document.getElementById('screen'); this.screen.obj.onselectstart = function () { return false; } this.screen.obj.ondrag = function () { return false; } this.mouseZ = mouseZ; this.camera.focalLength = FL; this.angle.rx = rx; this.angle.ry = ry; var i = 0, o; while( o = structure[i++] ) this.create3DHTML(o.img, o.x, o.y, o.z, o.sw, o.sh); this.resize(); mouse.y = this.screen.y + this.screen.h; mouse.x = this.screen.x + this.screen.w; setInterval(tv.run, 16); setInterval(tv.dFPS, 1000); }, resize : function () { var o = tv.screen.obj; if (o) { tv.screen.w = o.offsetWidth / 2; tv.screen.h = o.offsetHeight / 2; for (tv.screen.x = 0, tv.screen.y = 0; o != null; o = o.offsetParent) { tv.screen.x += o.offsetLeft; tv.screen.y += o.offsetTop; } } }, run : function () { tv.fps++; tv.angle.x.move(-(mouse.y - tv.screen.h - tv.screen.y) * tv.angle.rx, .1); tv.angle.y.move( (mouse.x - tv.screen.w - tv.screen.x) * tv.angle.ry, .1); tv.camera.x.move(tv.camera.x.target, .025); tv.camera.y.move(tv.camera.y.target, .025); tv.angle.cx = Math.cos(tv.angle.x.position); tv.angle.sx = Math.sin(tv.angle.x.position); tv.angle.cy = Math.cos(tv.angle.y.position); tv.angle.sy = Math.sin(tv.angle.y.position); var i = 0, o; while( o = tv.O[i++] ) o.animate(); }, dFPS : function () { document.getElementById('FPS').innerHTML = tv.fps + ' FPS'; tv.fps = 0; } } var mouse = { x : 0, y : 0 } document.onmousemove = function(e) { if (window.event) e = window.event; mouse.x = e.clientX; mouse.y = e.clientY; return false; } onload = function() { onresize = tv.resize; var img = document.getElementById('bankImages').getElementsByTagName('img'); var structure = []; for (var i = -300; i <= 300; i += 120) for (var j = -300; j <= 300; j += 120) structure.push({ img:img[0], x:i, y:j, z:0, sw:.5, sh:.5 }); tv.init(structure, 350, -200, .005, .0025); } </script> </head> <body> <div id="screen"></div> <div id="bankImages"> <img alt="" src="http://www.hbsxmp.com/images/wall1_s.jpg"> </div> <div id="FPS"></div> </body> </html> <br> <a href="http://www.hbsxmp.com">網頁代碼站</a> - 最專業的代碼下載網站 - 致力為中國站長提供有質量的代碼!
運行代碼
全選代碼
復制代碼
保存代碼
友情提示
圖片3D展示,鼠標晃動的時候圖片跟著就動了,點擊的時候會稍微放大一些,不同的角度會出現不一樣的效果,JavaScript與CSS結合共同形成的效果。
一、如果您使用的瀏覽器版本為IE6.0、360瀏覽器V3.0.8.1版本或者IE的更低版本瀏覽本頁面,建議您升級瀏覽器至IE7以上,上面的“運行”按鈕可能不能用,但您可按以下方式查看。
運行代碼方式:
1、點擊“復制”按鈕;
2、在桌面建立一個txt文檔;
3、粘貼復制的代碼;
4、最后把txt的擴展名改為“htm”或“html”;
5、完成,打開即可看到效果。
二、如果您使用FireFox或者非IE瀏覽器,建議您使用IE7以上版本。上面的“復制”按鈕失效,請您“全選”,以普通方式復制!
三、某些代碼因需加載完Jquery等之類比較大的JS文件,如果您看不到效果,請您刷新頁面!
四、某些代碼不能完全兼容各瀏覽器,還請您再次修改才能使用!給您帶來的不便!盡請諒解!謝謝您的支持!
上一篇:
字符在FORM中墜落
下一篇:
無關閉按鈕的窗口
JS圖片切換特效
常用JS圖片滾動(無縫、平滑、
完全利用CSS實現圖片切換特效
【薦】JavaScript圖片放大技術(
【薦】超絢的JavaScript立體圖片
防騰訊網的JS圖片切換代碼
CSS+JS控制遮罩效果的TAB及焦點圖
JS防阿里媽媽的圖片幻燈片代碼
js圖片漸隱漸現特效
JavaScript+Flash制作常用的焦點圖
問問
|
貼吧
|
查詢
|
給我留言
|
精品美文
|
友情鏈接
| |
本站承接網站開發業務
版權聲明
|
廣告服務
|
聯系我們
|
網站地圖
|
關于我們
| |
滇ICP備08101440號
Powered by
網頁代碼站
(網頁即"web" + 代碼即"dm" + "cn" = webdm.cn) | 最專業的代碼下載網站 - 致力為中國站長提供高質量的代碼!
滇公網安備 53032202100002號
精品久久久久久久中文字幕