<strong>一、在中间显示;(参考:<a href="http://www.jb51.net/article/26525.htm" target="_blank">sky100articles1790515)</a> <br></strong><div class="codetitle"> <span><a style="CURSOR: pointer" data="55486" class="copybut" id="copybut55486" onclick="doCopy('code55486')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code55486"> <br>.ordersearchDivCss <br>{ <br>position: absolute; <br>z-index: 100; <br>display: block; <br>background-color: #6ec1df; <br>} <br><div class="ordersearchDivCss" id="DivMain" style="width: 400px; height:200px" align="center"></div> <br> </div> <br>Js code <br>调用:<input type="button" id="Button1" onclick="sc1(‘DivMain')"> <br>// JScript 文件 通过元素id得到对象的函数 <br>function $(id) <br>{ <br>return document.getElementById(id); <br>} <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="47200" class="copybut" id="copybut47200" onclick="doCopy('code47200')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code47200"> <br>function sc1(DivId) { <br>var Div = $(DivId); <br>$(DivId).style.top = (document.documentElement.scrollTop + (document.documentElement.clientHeight - $(DivId).offsetHeight) / 2) + "px"; <br>$(DivId).style.left = (document.documentElement.scrollLeft + (document.documentElement.clientWidth - $(DivId).offsetWidth) / 2) + "px"; <br>//alert($(DivId).style.top); <br>} <br> </div> <br><strong>二、始终在中间显示,滚动时,在Js中增加以下代码: <br></strong><div class="codetitle"> <span><a style="CURSOR: pointer" data="25174" class="copybut" id="copybut25174" onclick="doCopy('code25174')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code25174"> <br>function scall() { <br>sc1("DivMain"); <br>} <br>window.onscroll = scall; <br>window.onresize = scall; <br>window.onload = scall; <br> </div>