How to increase the distance between table columns

2020-05-22 05:13发布

Let's say I wanted to create a single-rowed table with 50 pixels in between each column, but 10 pixels padding on top and the bottom.

How would I do this in HTML/CSS?

7条回答
Juvenile、少年°
2楼-- · 2020-05-22 05:41

If I understand correctly, you want this fiddle.

table {
  background: gray;
}
td {    
  display: block;
  float: left;
  padding: 10px 0;
  margin-right:50px;
  background: white;
}
td:last-child {
  margin-right: 0;
}
<table>
  <tr>
    <td>Hello HTML!</td>
    <td>Hello CSS!</td>
    <td>Hello JS!</td>
  </tr>
</table>

查看更多
登录 后发表回答