Application Development

Software technique, Skills & Applications

表格居中的解决方法 January 20, 2012

Filed under: css — meetme @ 3:22 am

From http://www.cnblogs.com/djune/archive/2009/08/05/1539861.html

  把原来用到align:center或text-align:center的地方用在对应的style里面用margin: 0px auto替换。这样既可以在火狐中居中也可以再IE中居中。
以下是具体代码:
这个是我第一次写的居中表格的源代码:【只能在IE7中居中】<div style=”text-align:center”>  
<table  border=”1″ cellspacing=”0″ style=”border-collapse: collapse; border-color:Black;”> 
      <tr>
            <td>第一列</td>
            <td>第二列</td>
      </tr>
</table>
<div>
   
这个是我更改后的部分源代码:【即能在IE7中居中又能在火狐中居中】<table  border=”1″ cellspacing=”0″ style=”border-collapse: collapse; border-color:Black; margin: 0px auto; “> 
      <tr>
            <td>第一列</td>
            <td>第二列</td>
      </tr>
</table>

版权所有djune@博客园2009 哥签的不是名,是寂寞…..
Advertisement
 

 
Follow

Get every new post delivered to your Inbox.