热门标签:   个人网站   个人网页   WAP网站   网页特效   网页教程   收藏本站   设为主页  
首 页   个人网站   个人博客   WAP网站   网页特效   网页教程   软件教程   我要参展
帐 号: 密 码:
 
网站及资源搜索:  
 
  当前位置 > 中国个人网页秀-> 网页特效-> 页面特效-> 图形图像-> 小方框中浏览大图
小方框中浏览大图
整理:Cnwshow.Com   来源:Internet   整理时间:2008-6-19

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>小方框中浏览大图</title>
<style type="text/css">
<!--
#pic {
width:300px;
height:300px;
border: 3px solid #ccc;
background-image: url(204.jpg);
background-repeat: no-repeat;
background-position: 0px 0px;
cursor: move;
}
-->
</style>
<script type="text/javascript">
<!--
var p = new Array();
var speed = 0.05;  //速度
var picWidth = 1280;  // 大图的宽高
var picHeight = 971;
var x,y // 鼠标点下去时背景的坐标
var x_new,y_new  //位移
var haveclick = false;

function getmouseposition(event)
{
if(document.all)
{
x = document.body.scrollLeft+event.clientX;
y = document.body.scrollTop+event.clientY;
}else
{
x = event.layerX;
y = event.layerY;
}
haveclick = true;
}
function movestop()
{
haveclick = false;
}

function movestart(event)
{
if(haveclick)
{
if(document.getElementById('pic').style.backgroundPosition.length==0)
{document.getElementById('pic').style.backgroundPosition="0px 0px";}
p = document.getElementById('pic').style.backgroundPosition.split(" ")

if(document.all)
{
x_new = document.body.scrollLeft+event.clientX;
y_new = document.body.scrollTop+event.clientY;
}else
{  
x_new = event.layerX;
y_new = event.layerY;
}

x2 = (speed*(x_new-x)+parseInt(p[0])).toString(10);    // 计算位移量
y2 = (speed*(y_new-y)+parseInt(p[1])).toString(10);

if (x2<-picWidth+420) x2=-picWidth+420;
if (y2>0) y2=0;
if (x2>0) x2=0;
if (y2<-picHeight+300) y2=-picHeight+300;

document.getElementById('pic').style.backgroundPosition=x2+"px "+y2+"px";
}
}
-->
</script>
</head>

<body>
<div id="pic" onmousedown="getmouseposition(event)" onmousemove="movestart(event)" onmouseup="movestop()" onmouseout="movestop()"> </div>
</body>
</html>

运行代码预览特效
  图形图像 热门点击
·图片翻页效果代码
·自由变化大小的图片
·给图片加注释
·向上下左右滚动图片的特效
·像篮球一样跳动的图片
·水中倒影
·自由浮动图像特效
·鼠标让图片震动
·图片渐渐显隐
·图片渐渐显示
  酷站推荐
关于本站  联系本站  免责声明  使用帮助  网站搜索  网站地图
Copyright © 2005-2008 Cnwshow.Com Inc All Rights Reserved 中国个人网页秀
技术支持:网秀科技   QQ群:36941957  客服QQ:151483161  粵ICP备05134415号