日期:2014-05-20  浏览次数:20722 次

div定位问题(当点击一个图片按纽,图片居中显示)
<center> .... </center> 已经用过,没效果.
想用脚本控制:
if(xxxx"条件"xxx){
                  out.println( " <tr> ");
out.println( " <td   style= 'cursor:hand '> ");
out.println( " <dl> ");  
out.println( " <div   id=imageDiv   style=\ "position:absolute;display:none;left:inherit;   top:inherit;   \ "> <img   width= '400 '   height= '400 '   src=\ "../UploadFiles/ "+strURL+ "\ "   border=\ "2\ "   style=\ "border-color:#CC6600\ "> <input   type= 'button '   value= '关闭此图片 '   onclick= 'javascript:dispImage(\ "imageDiv\ ",\ "none\ ") '> </div> ");
out.println( " <span   onclick=divTT(\ "imageDiv1\ "); '> <font   size=\ "-1\ "> ");
        out.println( "事实照片 ");
out.println( " </font> ");
out.println( " </span> ");
out.println( " </dl> ");
out.println( " </td> ");
}
======脚本如:
<script   language= " ">
function   divTT(divImage){  
        //对象相对窗口顶端的高度(层)网页可见区域
var   divOffSetHeight   =   document.getElementById(divImage);
        divOffSetHeight.offSetHeight   =   divOffSetHeight.style.height;
        //屏幕的高
var   divClientHeight   =   window.screen.availHeight;
        //对象相对窗口顶端的宽度(层)网页可见区域
var   divOffSetWidth   =   document.getElementById(divImage);
divOffSetWidth.offSetWidth   =   divOffSetWidth.style.width;
      //屏幕率的宽
var   divClientWidth   =   window.screen.availWidth;

            //div   top
        document.getElementById(divImage).style.top   =   (   divClientHeight   -   divOffSetHeight.offSetHeight)/2   +   "px ";
//div   left
document.getElementById(divImage).style.left   =   (divClientWidth/2   -   divOffSetWidth.offSetWidth/2)   +   "px ";      
}
</script>


------解决方案--------------------
<div style= "text-align:center; ">
<img src= "ico/tabicons.png "/>
</div>