<div class="hcb_wrap">
<pre class="prism undefined-numbers lang-csharp" data-lang="JavaScript"><code> 
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; 
} 
 
// ä½¿ç¨ 
$( "#id" ).center(); 
</code></pre>
</div>
<hr>
<p>åºå ¸å <a href="https://stackoverflow.com/questions/210717/using-jquery-to-center-a-div-on-the-screen" rel="noopener noreferrer" target="_blank">Using jQuery to center a DIV on the screen</a></p>