div absolute 置中

来源:互联网 发布:python写抢票程序 编辑:程序博客网 时间:2024/05/21 09:01
jQuery.fn.center = function() {    this.css('position','absolute');    this.css('top', ( $(window).height() - this.height() ) / +$(window).scrollTop() + 'px');    this.css('left', ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + 'px');    return this;};// 使用方法$(element).center();
0 0