手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >JS模仿腾讯图片站的图片翻页按钮效果完整实例
JS模仿腾讯图片站的图片翻页按钮效果完整实例
摘要:本文实例讲述了JS模仿腾讯图片站的图片翻页按钮效果。分享给大家供大家参考,具体如下:运行效果截图如下:具体代码如下:模仿腾讯图片翻页*{ma...

本文实例讲述了JS模仿腾讯图片站的图片翻页按钮效果。分享给大家供大家参考,具体如下:

运行效果截图如下:

JS模仿腾讯图片站的图片翻页按钮效果完整实例1

具体代码如下:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>模仿腾讯图片翻页</title> <style type="text/css"> *{ margin:none; padding:none; } body{ background:#000000; } #tip{ position:absolute; width:564px; height:362px; top:-362px; background:url(../img/TencentImg/tipLayer.png); } #left{ position:absolute; width:101px; height:95px; background:url(../img/TencentImg/left.png); border:1px solid #f2f2f2; display:none; cursor:hand; } #right{ position:absolute; width:101px; height:95px; background:url(../img/TencentImg/right.png); border:1px solid #f2f2f2; display:none; cursor:hand; } #mouseXPosition{ width:30px; height:20px; color:#ffffff; display:inline; } #mouseYPosition{ width:30px; height:20px; color:#ffffff; display:inline; } #divTop{ width:30px; height:20px; color:#ffffff; display:inline; } </style> <script type="text/javascript"> function init(){ var ml = document.body.clientWidth/2 - 40; document.getElementById("left").style.pixelTop = 300; document.getElementById("right").style.pixelTop = 300; document.getElementById("left").style.pixelLeft = ml - 101*4; document.getElementById("right").style.pixelLeft = ml + 101*4; var tip = document.getElementById("tip"); var initH = (document.body.clientWidth - tip.offsetWidth)/2; document.getElementById("tip").style.left = initH; document.getElementById("tip").style.pixelTop = -362; } function mousePosition(ev){ if(ev.pageX || ev.pageY){ return {x:ev.pageX, y:ev.pageY}; } return { x:ev.clientX + document.body.scrollLeft - document.body.clientLeft, y:ev.clientY + document.body.scrollTop - document.body.clientTop }; } document.onmousemove = mouseMove; function mouseMove(e){ e = e || window.event; var mousePos = mousePosition(e); var mid = document.body.clientWidth/2; document.getElementById('mouseXPosition').innerHTML = mousePos.x; document.getElementById('mouseYPosition').innerHTML = mousePos.y; if(mousePos.x < mid){ document.getElementById("left").style.display = "block"; document.getElementById("right").style.display = "none"; }else if(mousePos.x > mid){ document.getElementById("right").style.display = "block"; document.getElementById("left").style.display = "none"; } } function show(){ if(document.getElementById("tip").style.pixelTop < 80){ document.getElementById("tip").style.pixelTop += 20; document.getElementById("divTop").innerHTML = document.getElementById("tip").style.pixelTop; setTimeout("show()",10) } } function hide(){ if(document.getElementById("tip").style.pixelTop > -362){ document.getElementById("tip").style.pixelTop -= 20; document.getElementById("divTop").innerHTML = document.getElementById("tip").style.pixelTop; setTimeout("hide()",10) } } </script> </head> <body onload="init()"> <div id = "left"></div> <div id = "right"></div> <span style = "color:#ffffff;">鼠标 X 轴:</span> <div id="mouseXPosition">0</div><br/> <span style = "color:#ffffff">鼠标 Y 轴:</span> <div id="mouseYPosition">0</div><br/> <span style = "color:#ffffff;font-size:13px;">图片上边距:</span> <div id = "divTop">0</div> <div id = "tip">0</div> </body> </html>

希望本文所述对大家JavaScript程序设计有所帮助。

【JS模仿腾讯图片站的图片翻页按钮效果完整实例】相关文章:

CSS+JS构建的图片查看器

Javascript实现div的toggle效果实例分析

js+css实现回到顶部按钮(back to top)

JavaScript实现的MD5算法完整实例

一个很简单的办法实现TD的加亮效果.

解决未知尺寸的图片撑破页面的问题

jQuery实现的多屏图像图层切换效果实例

javascript实现图片跟随鼠标移动效果的方法

JavaScript实现带标题的图片轮播特效

jquery实现弹出层效果实例

精品推荐
分类导航