How to set cellspacing in tables only horizontally

梦想与她 提交于 2019-12-01 00:59:27

问题


I would like to style the table written below.

<table border="1"   cellspacing="10">
  <tr>
    <th>Month</th>
    <th>Savings</th>  
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table>

The problem is that cellspacing sets the space between cells both horizontaly and verticaly, I would like it to be done only horizontaly. Is there a way to do this.


回答1:


Use the border-spacing CSS property on the table. Browser support is fairly good (excluding mainly IE up to and including IE 7). Example:

table { border-spacing: 10px 0; }



回答2:


Try CSS

table td{

 padding:0px 10px 0px 10px; /* top right bottom left */

 }


来源:https://stackoverflow.com/questions/12970826/how-to-set-cellspacing-in-tables-only-horizontally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!