1
我有一个div
和img
这需要围绕在窗已经扩展jQuery的功能,为了做到这一点使用此功能:页面加载之前居中容器使用jQuery
jQuery.fn.center = function() {
this.css("position","absolute");
this.css("top", Math.max(0, (($(window).height() - this.outerHeight())/2) +$(window).scrollTop()) + "px");
this.css("left", Math.max(0, (($(window).width() - this.outerWidth())/2) + $(window).scrollLeft()) + "px");
return this;
}
此功能完美但唯一的问题是图像首先加载它的默认位置,然后移动到中心。如何让图像直接在页面加载中心看到?
编辑:这里就是我的意思:www.foxteam.net/portfolio.php