论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > Javascript教程
Tag:验证,特效,入门,实例,验证,表单,特效,正则表达式,跑马灯,document,函数,代码,getElementByID,菜单,图片,视频教程

编写类似VANCL产品图片放大的效果 源码

文章类别:Javascript | 发表日期:2010-3-27 12:20:45

21视频教程网3月27日整理

在本地调试IE中没问题,怎么上传了在IE里就不起作用了??奇怪。FF中没问题。
(点"运行代码"按钮后,待页面打开完,再按F5刷新一下页面)

<!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 runat="server">
    <title>Clip Test</title>
    <style type="text/css">
        body
        {
            margin:0;
            padding:15px;
        }
    .clip
    {
        position: relative;
        height: 499px;
        width: 333px;
        border: solid 1px #ccc;
        cursor:default;
        background:#fff;
    }
    .clip div {
        position: absolute;
        clip: rect(0px 60px 100px 0px);
        width:333px;
        height:499px;
        background:url(http://home.blueidea.com/attachment/201003/5/76563_126775682722DJ.gif) no-repeat top left;
        cursor:default;
    }
    .pic
    {
        position: absolute;
        height: 499px;
        width: 333px;
        top:15px;
        left:353px;
        border: solid 1px #ccc;
        background-image:url(http://home.blueidea.com/attachment/201003/5/76563_1267756832oAOz.jpg);
        background-repeat: no-repeat;
        background-position:0px 0px;
    }
    </style>
    <script type="text/javascript" language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
    <script type="text/javascript" language="javascript">
        $(function() {
            $("#mov").mousemove(function(event) { MoveRect(event); });
        });
        var moverW = 60;
        var moverH = 100;
        function MoveRect(event) {
            var x = event.clientX - 15;
            var y = event.clientY - 15;
            var top = y - moverH / 2;
            var right = x + moverW / 2;
            var bottom = y + moverH / 2;
            var left = x - moverW / 2;
            if (top <= 0) {
                top = 0;
                bottom = moverH;
            }
            if (left <= 0) {
                left = 0;
                right = moverW;
            }
            if (top >= 499 - moverH) {
                top = 499 - moverH;
                bottom = top + moverH;
            }
            if (left >= 333 - moverW) {
                left = 333 - moverW;
                right = left + moverW;
            }
            $("#img").css("clip", "rect(" + top.toString() + "px " + right.toString() + "px " + bottom.toString() + "px " + left.toString() + "px)");
            $("#posi").html(x + ":" + y + " - " + $("#img").css("clip"));
            $("#pic").css("background-position", (0 - left * 2.5 * 2) + "px " + (0 - top * 2.5 * 2) + "px");
        }
        function SetBG(bg) {
            $("#mov").css("background", bg);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="clip" id="mov">
        <div id="img"></div>
    </div>
    <div class="pic" id="pic"></div>
    <div id="posi"></div>
    <div>
        背景:
        <a href="javascript:void(0);" onclick="javascript:SetBG('#fff');">无</a>
        <a href="javascript:void(0);" onclick="javascript:SetBG('url(http://home.blueidea.com/attachment/201003/5/76563_1267756835yzlE.gif) no-repeat top left');">有</a>
        <a href="javascript:void(0);" onclick="javascript:SetBG('url(http://home.blueidea.com/attachment/201003/5/76563_12677568353HQg.gif) no-repeat top left');">模糊</a>
    </div>
    </form>
</body>
</html>

视频教程列表
文章教程搜索
 
Javascript推荐教程
Javascript热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058