<SPAN style="FONT-SIZE: medium"> <script type="text/javascript" src="js/jquery-1.4.2.js"></script> <script type="text/javascript"> $(document).ready(function() { jQuery.fn.center = function() { this.css("position", "absolute"); this.css("top", ($(window).height() - this.height()) / 2 + $(window).scrollTop() + "px"); this.css("left", ($(window).width() - this.width()) / 2 + $(window).scrollLeft() + "px"); return this; } $("#id").center(); }); </script> </SPAN> <SPAN style="FONT-SIZE: medium">//ID为要在屏幕上下左右居中的元素ID,而不是class</SPAN>