e if(realWidth>windowW*scale) {//如图片高度合适,判断图片宽度   imgWidth = windowW*scale;//如大于窗口宽度,图片宽度进行缩放   imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度   } else {//如果图片真实高度和宽度都符合要求,高宽*2  imgWidth = realWidth; imgHeight = realHeight; } $(bigimg).css("width",imgWidth);//以最终的宽度对图片缩放   var w = (windowW-imgWidth)/2;//计算图片与窗口左边距   var h = (windowH-imgHeight)/2;//计算图片与窗口上边距   $(innerdiv).css({"top":h, "left":w});//设置#innerdiv的top和left属性   $(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg   }); $(outerdiv).click(function(){//再次点击淡出消失弹出层   $(this).fadeOut("fast"); }); } $("#innerdiv").click(function(){//再次点击淡出消失弹出层   $("#outerdiv").fadeOut("fast"); });