我有这样的代码......jQuery的浏览器调整大小股利中心即使在滚动
<style type="text/css">
#container {
width: 200px;
height: 200px;
background-color: #567;
}
</style>
<div id="container">
My center div...
</div>
<script type="text/javascript">
$(window).resize(function(){
$('#container').css({
position:'absolute',
left: ($(window).width() - $('#container').outerWidth())/2,
top: ($(window).height() - $('#container').outerHeight())/2
});
});
// To initially run the function:
$(window).resize();
</script>
这个伟大的工程,除非我滚动到页面的底部,它不会在浏览器中的中间居中DIV屏幕基于我在页面位置的新坐标。所以我的问题是,如果我点击打开这个DIV,如果我滚动到长页面的底部,我能做些什么来集中DIV?
这工作真棒!谢谢@whiteatom – Joe 2012-03-14 21:33:14