jQuery工具覆盖定位在左侧而不是中间

jQuery工具覆盖定位在左侧而不是中间,jquery,overlay,jquery-tools,Jquery,Overlay,Jquery Tools,我试图在页面中央显示一个覆盖图,我按照jQuery工具文档(这是一个糟糕的文档!)来显示它,但它没有为我正确定位,它一直位于页面的左侧 通过一些谷歌搜索,我能够找出问题所在,但无法解决问题,这是jQuery工具和jQuery 1.8.0之间的冲突: 但我不知道如何修复它,我无法更改我的JQuery库,因为它用于大型产品中,更新或降级可能会导致问题 我能够用jQuery1.8.0在JSFIDLE上复制它 Javascript: jQuery("a[rel]").overlay({ ma

我试图在页面中央显示一个覆盖图,我按照jQuery工具文档(这是一个糟糕的文档!)来显示它,但它没有为我正确定位,它一直位于页面的左侧

通过一些谷歌搜索,我能够找出问题所在,但无法解决问题,这是jQuery工具和jQuery 1.8.0之间的冲突:

但我不知道如何修复它,我无法更改我的JQuery库,因为它用于大型产品中,更新或降级可能会导致问题

我能够用jQuery1.8.0在JSFIDLE上复制它

Javascript:

jQuery("a[rel]").overlay({
    mask: {zIndex:100,color:'#000000',opacity: 0.5,loadSpeed:'fast'}, onBeforeLoad:function(){
    var wrap = this.getOverlay().find(".contentWrap");
    var html = '<iframe width="100%" scrolling="yes" height="100%" frameborder="0" marginwidth="0" marginheight="0" src="'+this.getTrigger().attr("href")+'">';
    wrap.html(html);
  }
});
这是我随附的覆盖代码:

(function(a){a.tools=a.tools||{version:"v1.2.7"},a.tools.overlay={addEffect:function(a,b,d){c[a]=[b,d]},conf:{close:null,closeOnClick:!0,closeOnEsc:!0,closeSpeed:"fast",effect:"default",fixed:!a.browser.msie||a.browser.version>6,left:"center",load:!1,mask:null,oneInstance:!0,speed:"normal",target:null,top:"10%"}};var b=[],c={};a.tools.overlay.addEffect("default",function(b,c){var d=this.getConf(),e=a(window);d.fixed||(b.top+=e.scrollTop(),b.left+=e.scrollLeft()),b.position=d.fixed?"fixed":"absolute",this.getOverlay().css(b).fadeIn(d.speed,c)},function(a){this.getOverlay().fadeOut(this.getConf().closeSpeed,a)});function d(d,e){var f=this,g=d.add(f),h=a(window),i,j,k,l=a.tools.expose&&(e.mask||e.expose),m=Math.random().toString().slice(10);l&&(typeof l=="string"&&(l={color:l}),l.closeOnClick=l.closeOnEsc=!1);var n=e.target||d.attr("rel");j=n?a(n):null||d;if(!j.length)throw"Could not find Overlay: "+n;d&&d.index(j)==-1&&d.click(function(a){f.load(a);return a.preventDefault()}),a.extend(f,{load:function(d){if(f.isOpened())return f;var i=c[e.effect];if(!i)throw"Overlay: cannot find effect : \""+e.effect+"\"";e.oneInstance&&a.each(b,function(){this.close(d)}),d=d||a.Event(),d.type="onBeforeLoad",g.trigger(d);if(d.isDefaultPrevented())return f;k=!0,l&&a(j).expose(l);var n=e.top,o=e.left,p=j.outerWidth({margin:!0}),q=j.outerHeight({margin:!0});typeof n=="string"&&(n=n=="center"?Math.max((h.height()-q)/2,0):parseInt(n,10)/100*h.height()),o=="center"&&(o=Math.max((h.width()-p)/2,0)),i[0].call(f,{top:n,left:o},function(){k&&(d.type="onLoad",g.trigger(d))}),l&&e.closeOnClick&&a.mask.getMask().one("click",f.close),e.closeOnClick&&a(document).on("click."+m,function(b){a(b.target).parents(j).length||f.close(b)}),e.closeOnEsc&&a(document).on("keydown."+m,function(a){a.keyCode==27&&f.close(a)});return f},close:function(b){if(!f.isOpened())return f;b=b||a.Event(),b.type="onBeforeClose",g.trigger(b);if(!b.isDefaultPrevented()){k=!1,c[e.effect][1].call(f,function(){b.type="onClose",g.trigger(b)}),a(document).off("click."+m+" keydown."+m),l&&a.mask.close();return f}},getOverlay:function(){return j},getTrigger:function(){return d},getClosers:function(){return i},isOpened:function(){return k},getConf:function(){return e}}),a.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","),function(b,c){a.isFunction(e[c])&&a(f).on(c,e[c]),f[c]=function(b){b&&a(f).on(c,b);return f}}),i=j.find(e.close||".close"),!i.length&&!e.close&&(i=a("<a class=\"close\"></a>"),j.prepend(i)),i.click(function(a){f.close(a)}),e.load&&f.load()}a.fn.overlay=function(c){var e=this.data("overlay");if(e)return e;a.isFunction(c)&&(c={onBeforeLoad:c}),c=a.extend(!0,{},a.tools.overlay.conf,c),this.each(function(){e=new d(a(this),c),b.push(e),a(this).data("overlay",e)});return c.api?e:this}})(jQuery);
(函数(a){a.tools=a.tools |{version:“v1.2.7”},a.tools.overlay={addEffect:function(a,b,d){c[a]=[b,d]},conf:{close:null,closeOnClick:!0,closeOnEsc:!0,closeSpeed:“fast”,effect:“default”,修复:!a.browser.msie | | a.browser.version>6,左:“中心”,加载:!1,掩码:null,一个实例:!0,速度:“正常”,目标:10%[],[];a.tools.overlay.addEffect(“默认”,函数(b,c){var d=this.getConf(),e=a(窗口);d.fixed |(b.top+=e.scrollTop(),b.left+=e.scrollLeft()),b.position=d.fixed?“固定”:“绝对”,this.getOverlay().css(b.fadeIn(d.speed,c)},函数(a){this.getOverlay().fadeOut(this.getConf().closeSpeed,a)});函数d(d,e,e){var=f=this,f,g=d,f=d(window)i,j,k,k,l=l=a.i,i,j,k,k,k,l=l=a.工具.工具.暴露和(e.mask| | e.mask | e.mask | e.mask | e.mask | e.mask | e.暴露),m=m=数学.随机.随机.toString.toString.toString.toString.toString.toString.切片.切片(10)切片(10)切片(10;l和(10;l和(10)l和(l和(l和(T)l和(类型的l和(l&)l和(l和(T)l和(类型l&(l=(类型l=l=(类型l=l=l=“l=====“字符串====“字符串”以及(类型l==“字符串”字符串”字符串”字符串”和(l=={加载:函数(d){if(f.isOpened())返回f;var i=c[e.effect];if(!i)throw“Overlay:找不到效果:\”“+e.effect+”\”“;e.oneInstance&&a.each(b,function(){this.close(d)}),d=d | a.Event(),d.type=“onBeforeLoad”,g.trigger(d);if(d.isDefaultPrevented())返回f;k=!0,l&&a(j)。expose(l);var n=e.top,o=e.left,p=j.outerwight(!routh:{;typeof n==“string”&(n=n==“center”?Math.max((h.height()-q)/2,0):parseInt(n,10)/100*h.height()),o==“center”&(o=Math.max((h.width()-p)/2,0)),i[0]。调用(f,{top:n,left:o},function(){k&(d.type=“onLoad”,g.trigger(d)),l&&e.closeOnClick&&a.mask.getMask().one(&&a.getMask())。一次(“click”,f.close),e.close),e.click,e.a)点击父对象(b){.length | | f.close(b)}),e.closeOnEsc&&a(document).on(“keydown.”+m,函数(a){a.keyCode==27&&f.close(a)});return f},close:function(b){if(!f.isOpened())return f;b=b | a.Event(),b.type=“onBeforeClose”,g.trigger(b);if(!b.isDefaultPrevented()){k=!1,c[e.effect][1]。调用(f,function(){b.type=”,trigger-off)函数(+m.),单击“关闭”),l&&a.mask.close();return f},getOverlay:function(){return j},getTrigger:function(){return d},getcloser:function(){return i},isOpened:function(){return k},getConf:function(){return e e e},a.each(“onBeforeLoad,onStart,onLoad,onbeforecose,onClose,onClose”).split(“,”),function(b,c){a.isFunction(e[c])&a(e[c])&a(c]),on(c){)(i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.i.);返回c.api?e:this}(jQuery);

当您检查元素时,页面上是否存在覆盖您所尝试内容的样式?它似乎在JSFIDLE上按预期工作。确保您的工作代码与FIDDLE上显示的覆盖匹配,内容显示在覆盖中,单击覆盖清除覆盖,内容。。。有什么问题吗?如果它是一个居中的东西,您的iFrame是
width=“100%”
,因此它将占据整个东西。我已经用确切的问题对它进行了更新,它与jquery 1.8有关,并更新了JSFIDLE,因此它将反映我的问题
.container { width:400px; margin:0 auto; }
.contentWrap { height:441px; }
.wrapper { display:none; background:#fff; width:800px; padding:10px; }
(function(a){a.tools=a.tools||{version:"v1.2.7"},a.tools.overlay={addEffect:function(a,b,d){c[a]=[b,d]},conf:{close:null,closeOnClick:!0,closeOnEsc:!0,closeSpeed:"fast",effect:"default",fixed:!a.browser.msie||a.browser.version>6,left:"center",load:!1,mask:null,oneInstance:!0,speed:"normal",target:null,top:"10%"}};var b=[],c={};a.tools.overlay.addEffect("default",function(b,c){var d=this.getConf(),e=a(window);d.fixed||(b.top+=e.scrollTop(),b.left+=e.scrollLeft()),b.position=d.fixed?"fixed":"absolute",this.getOverlay().css(b).fadeIn(d.speed,c)},function(a){this.getOverlay().fadeOut(this.getConf().closeSpeed,a)});function d(d,e){var f=this,g=d.add(f),h=a(window),i,j,k,l=a.tools.expose&&(e.mask||e.expose),m=Math.random().toString().slice(10);l&&(typeof l=="string"&&(l={color:l}),l.closeOnClick=l.closeOnEsc=!1);var n=e.target||d.attr("rel");j=n?a(n):null||d;if(!j.length)throw"Could not find Overlay: "+n;d&&d.index(j)==-1&&d.click(function(a){f.load(a);return a.preventDefault()}),a.extend(f,{load:function(d){if(f.isOpened())return f;var i=c[e.effect];if(!i)throw"Overlay: cannot find effect : \""+e.effect+"\"";e.oneInstance&&a.each(b,function(){this.close(d)}),d=d||a.Event(),d.type="onBeforeLoad",g.trigger(d);if(d.isDefaultPrevented())return f;k=!0,l&&a(j).expose(l);var n=e.top,o=e.left,p=j.outerWidth({margin:!0}),q=j.outerHeight({margin:!0});typeof n=="string"&&(n=n=="center"?Math.max((h.height()-q)/2,0):parseInt(n,10)/100*h.height()),o=="center"&&(o=Math.max((h.width()-p)/2,0)),i[0].call(f,{top:n,left:o},function(){k&&(d.type="onLoad",g.trigger(d))}),l&&e.closeOnClick&&a.mask.getMask().one("click",f.close),e.closeOnClick&&a(document).on("click."+m,function(b){a(b.target).parents(j).length||f.close(b)}),e.closeOnEsc&&a(document).on("keydown."+m,function(a){a.keyCode==27&&f.close(a)});return f},close:function(b){if(!f.isOpened())return f;b=b||a.Event(),b.type="onBeforeClose",g.trigger(b);if(!b.isDefaultPrevented()){k=!1,c[e.effect][1].call(f,function(){b.type="onClose",g.trigger(b)}),a(document).off("click."+m+" keydown."+m),l&&a.mask.close();return f}},getOverlay:function(){return j},getTrigger:function(){return d},getClosers:function(){return i},isOpened:function(){return k},getConf:function(){return e}}),a.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","),function(b,c){a.isFunction(e[c])&&a(f).on(c,e[c]),f[c]=function(b){b&&a(f).on(c,b);return f}}),i=j.find(e.close||".close"),!i.length&&!e.close&&(i=a("<a class=\"close\"></a>"),j.prepend(i)),i.click(function(a){f.close(a)}),e.load&&f.load()}a.fn.overlay=function(c){var e=this.data("overlay");if(e)return e;a.isFunction(c)&&(c={onBeforeLoad:c}),c=a.extend(!0,{},a.tools.overlay.conf,c),this.each(function(){e=new d(a(this),c),b.push(e),a(this).data("overlay",e)});return c.api?e:this}})(jQuery);