$(window).resize(function(){ $(".mydiv").css({ position: "absolute", left: ($(window).width() - $(".mydiv").outerWidth())/2, top: ($(window).height() - $(".mydiv").outerHeight())/2 }); }); // 然后在页面加载时 $(function(){ $(window).resize(); });
时间: 2024-11-02 04:13:35