框架调用的default.aspx
框架如下:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
     
</head>
 <frameset framespacing="1" border="0" frameborder="0" rows="70,*,25">
   <form id="form1" runat="server"> 
<frame name="top" scrolling="no" noresize="noresize" target="contents" src="top.aspx" marginheight="4">
<frameset cols="140,8,*" name="main_m">
<frame name="left"  src="left.aspx?power=<%=power%>" scrolling="auto" noresize="noresize" target="main" >
 <frame name="cen"  src="default.aspx" marginwidth="0" marginheight="0" scrolling="auto" noresize="noresize" style="padding: 0px">
<frame name="main" src="index_left.aspx" marginwidth="0" marginheight="0" scrolling="auto" noresize="noresize" style="padding: 0px">
</frameset>
<frame name="bottom" scrolling="no" noresize="noresize"  src="boot.aspx" style=" vertical-align:top" marginheight="2">
<noframes>
<body>
<p>此网页使用了框架,但您的浏览器不支持框架。</p> </body>
</noframes>
</form>
</frameset> 文件名:default.aspx<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>
<script language="JavaScript" type="text/javascript">
<!--
function changeState()   
{   
    if(parent.document.getElementById('main_m').cols!="140,8,*")   
    {   
        parent.document.getElementById('main_m').cols="140,8,*";   
        parent.document.getElementById('left').style.display="";   
        image1Id.src = "../images/left.gif";   
    }   
    else  
    {   
        parent.document.getElementById('main_m').cols = "0,8,*";   
        parent.document.getElementById('left').style.display="none";   
        image1Id.src = "../images/right.gif";   
         
    }   
}  //-->
</script></head>
<body style="background-color:Blue;" >
    <form id="form1" runat="server">
        <div>
        <table height="100%" cellspacing="0" cellpadding="0" border="0"  >  
            <tbody>  
                <tr  >  
                    <td height="100%" style="width: 9px; vertical-align: middle; text-align: center;"  >  
                   
                        <img id="image1Id" src="images/left.gif"  onclick="changeState();"  alt="关闭/打开左栏"  border="0" />
                        
                    </td>  
                </tr>  
            </tbody>  
        </table>  
        </div>
    </form>
</body>
</html>
就是里面那个<img id="image1Id" src="images/left.gif"  onclick="changeState();"  alt="关闭/打开左栏"  border="0" />死活不垂直居中,在页面里看是正常的居中了,可是运行起来还是不居中.图片有时还不变?郁闷啊!光前台代码,无后台的!谢谢!是不是和IE有关系?

解决方案 »

  1.   

    加<center>试试<center>
    <table height="100%" cellspacing="0" cellpadding="0" border="0"  >  
    .......</table>
    <center>
      

  2.   

    或者
    <center> 
    <img id="image1Id" src="images/left.gif"  onclick="changeState();"  alt="关闭/打开左栏"  border="0" />
    </center>
      

  3.   

    把框架里的default.aspx页面的style效果调到居中试试。
      

  4.   

    <td height="100%" style="width: 9px; height:100%; line-height:100%; vertical-align: middle; text-align: center;"  > <img id="image1Id" src="images/left.gif"  onclick="changeState();"  alt="关闭/打开左栏"  border="0" /></td>
      

  5.   

    align="center"        <div>
            <table height="100%" cellspacing="0" cellpadding="0" border="0" align="center">  
                <tbody>  
                    <tr>  
                        <td height="100%" style="width: 9px; vertical-align: middle; text-align: center;"  >  
                       
                            <img id="image1Id" src="images/left.gif"  onclick="changeState();"  alt="关闭/打开左栏"  border="0" />
                            
                        </td>  
                    </tr>  
                </tbody>  
            </table>  
            </div>
      

  6.   

    可以居中的
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Untitled Page</title>
        <style>
        html,body,form,table,div{height:100%}
        </style>
    </head>
    <body style="background-color:Blue;">
        <form id="form1" runat="server">
            <div>
            <table cellspacing="0" cellpadding="0" border="0">  
                <tbody>  
                    <tr>  
                        <td style="width: 9px; vertical-align: middle; text-align: center;">                     
                            <img id="image1Id" src="images/left.gif"  onclick="changeState();"  alt="关闭/打开左栏"  border="0" />                        
                        </td>  
                    </tr>  
                </tbody>  
            </table>  
            </div>
        </form>
    </body>
    </html>
      

  7.   

     <style>
        html,body,form,table,div{height:100%}
        </style>加上这个后,出现下拉条了
      

  8.   

    呵呵,xhtml有个“癖好”,你必须先为body设置高度为100%,然后才能控制里边的html对象垂直对齐规则。
      

  9.   


    仅仅设置body,别的不应该。
      

  10.   

    什么意思?这样?:
    <style>
        body{height:100%}
        </style>
      

  11.   

    LZ是IE8吧,
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    把这句话注释掉你的烦恼就解除了
      

  12.   


    wartim
     我是IE6,为什么我每次点击全是这一个图呢?
      

  13.   

    提示我ID没定义:image1Id????????????
      

  14.   

    什么不行啊???
    要不显示滚动条这样就可以    <style>
        html,body,form,table,div{height:100%;margin:0;padding:0}
        </style>
    删除
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    是不合理的不学会使用
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    你以后会很麻烦的
      

  15.   

    孟老大说得太对了,不要只看眼前利益,方法有很多的,这样也行
        <title>Untitled Page</title>
        <style>
        html,body,form,table,div{height:100%; overflow-y:hidden;}
        </style>
      

  16.   

    孟老大,分结早了,不好意思啊!
       <style> 
        html,body,form,table,div{height:100%;margin:0;padding:0} 
        </style> 
    用这个出现下拉条.也不显示出来,去掉那个就可以正常显示.还请老大指点!