我收到了一些以网页中间的div为中心的代码。该代码在Chrome上效果很好,但出于某种原因,在IE上(我认为它是9或10),它第一次工作,然后它不。Internet Explorer中心DIV问题
为了说明这个问题,这里有一些照片:(忽略你不明白的迹象,这就是我的语言)
铬:
IE我第一次点击的对象开拓:
IE第二时间以上,当我点击一个objec吨至打开:
这是我使用居中DIV代码:
jQuery.fn.center = function()
{
this.css("position","fixed");
this.css("top", ($(window).height()/2) - (this.outerHeight()/2));
this.css("left", ($(window).width()/2) - (this.outerWidth()/2));
return this;
}
使用该center()
函数的代码:
$('#products,#search-result').on("click",'.product-item-info',function() {
var pid = $(this).find('input').val();
$.get('product_info.php',{pid:pid},function(data){
$('#product-lb').html(data).append('<span class="x"><span>X</span></span>');
$('.x').click(function() {
$('#dimmer').click();
});
$('#dimmer').css({width:$('html').width(),height:$('html').height()});
$('#product-lb').center();
$('#product-lb').show(800);
$('#dimmer').show();
$(window).resize(function() {
$('#product-lb').center();
});
});
});
解释: #products
是包含所有彩色div的div以蓝色和绿色显示,如图所示 .product-item-info
是可以在每个产品DIV中找到的矩形类。 #dimmer
是黑色背景 #product-lb
是具有为中心,并在页面
上显示的DIV我希望这是足够的信息!如果您需要更多,请随时询问。
提前致谢!
你能摆弄这一个或提供一个链接到您的网站? –
@GaneshPandhere我会发布一个链接到一个demontration网站。出于某种原因,我的主人在这个地方遇到了困难,所以它还需要几分钟的时间。 – kfirba
@GaneshPandhere不幸的是,我的共享IP地址似乎在DDOS攻击下,因此,共享IP地址被过滤,这将需要一段时间,因为我可以在这里发布链接。 – kfirba