anniu1.style.display="none";先用这个隐藏后anniu1.style.display="block"; 再用这个显示出来不居中了``我的代码如下CSS的代码:
#KS 
{text-align:center;}HTML的代码:
<div id="KS">
        <input id="btn" class="ButtonA" style="display:none;width:300px;" type="submit" />
</div>
请问该怎么样弄``

解决方案 »

  1.   

    按钮的前后各加一个&nbsp;看看
      

  2.   

    没有发现这个问题噢
    测试用的代码
    <!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>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <style type="text/css">
    #KS 
    {text-align:center;} </style>
    </head><body>
    <div id="KS"> 
            <input id="btn" class="ButtonA" style="width:300px;" type="submit" /> 
    </div> 
    <input value="qurding" type="button"  onclick="ss(document.getElementById('btn'))"/>
    <script>
    function ss(o){
    o.style.display=o.style.display =="none"?"":"none"
    }
    </script>
    </body>
    </html>
      

  3.   

    一样没效果``我在js里显示的同时用了anniu1.style.textAlign="center"; 也不行```
      

  4.   

    有可能是其他地方的样式影响了DIV
    <div id="KS" style="text-align:center;"> 
            <input id="btn" class="ButtonA" style="width:300px;" type="submit" /> 
    </div>
    这样子