• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
wjshan0808

Learn from yesterday, Live for today, For a better tomorrow.
 ————wjshan0808

博客园    首页    新随笔    联系   管理    订阅  订阅

鼠标滚轮改变图片大小

    <script type="text/javascript">
 
        window.onresize = function () {
            shade.style.height = document.documentElement.clientHeight + "px";
            shade.style.width = document.documentElement.clientWidth + "px";
            ImageCenter();
        } 
        function ImageCenter() {
            divDetail.style.left = (document.documentElement.clientWidth - divDetail.clientWidth) / 2 + "px";
            divDetail.style.top = (document.documentElement.clientHeight - divDetail.clientHeight) / 2 + "px";
        }

        function MakeSize(e) {
            var zoom = parseInt(e.style.zoom, 10) || 100;
            zoom += event.wheelDelta / 12;
            if (zoom > 360)
                return;
            if (zoom > 0)
                e.style.zoom = zoom + '%';
            ImageCenter();
        } 


    </script>
    <div id="Shade" style="opacity: 0.5; position: absolute; left: 0px; top: 0px; z-index: 1000;
        background: rgb(0, 0, 0);" onclick="ShadeClick();">
    </div>
    <div id="divDetail" style="zoom: 1; opacity: 1; position: absolute; z-index: 1001;">
        <img id="detailImage" onmousewheel="return MakeSize(this);" style="cursor: pointer;">
    </div>

 


posted @ 2015-01-08 12:09  wjshan0808  阅读(210)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3