table表格整體居中


代碼:

1 <div style="text-align:center">
2     <table border="1" cellpadding="3" cellspacing="0" style="width: 60%;margin:auto">
3        <tr><td>4545</td> </tr>
4     </table>
5 </div>

如果只是單單用第一行代碼,表格整體不會居中,但是字體會居中,這是因為text-align屬性代表市元素中文本的水平對齊方式,只針對文本內容所以我們還需要再加一行

<table border="1" style="margin: auto;" width='60%'>
      ......
</table>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM