jquery 让div居中显示

function showsearch()
{
	 var wnd = $(window), doc = $(document);
	  var left = doc.scrollLeft();
	  var top = doc.scrollTop();
	 left += (wnd.width() - $("#seachdiv").width())/2;
	  top += (wnd.height() - $("#seachdiv").height())/2;
	   $("#seachdiv").css("position","absolute");
	  $("#seachdiv").css("top",top);
	  $("#seachdiv").css("left",left);
	 if($("#seachdiv").css("display")=="none")
	 {
		 $("#seachdiv").show("slow");
	 }else
	 {
		 $("#seachdiv").hide("slow");
	 }
		
	
}

你可能感兴趣的:(JavaScript,window,document,showsearch)