到目前为止,我只设法使用边框间距属性在每一列之间添加间距。当我使用这个属性时,我意识到每一列的左边和右边都有空格。是否可以使用css规则,以便仅在右侧应用间距?
下面是我当前方法的代码片段:
.table{
border-spacing: 10px 0;
}<!DOCTYPE html>
<html>
<head>
<title>html table</title>
</head>
<body>
<!-- Start your code here -->
<table class="table" >
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td><input type="text" value="some text"/></td>
<td><input type="text" value="another text"/></td>
<td><input type="text" value="looks like you giving"/></td>
</tr>
</table>
<!-- End your code here -->
</body>
</html>
谢谢你的帮助。
发布于 2018-06-13 00:27:28
你不能在表格的特定部分应用间距,也不能在td或td上设置页边距,一个解决方案是在<td>上使用padding。
table {
border-spacing: 0;
}
td {
padding-right: 10px
}<!--border for refrence -->
<table border="1">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td><input type="text" value="" /></td>
<td><input type="text" value="" /></td>
<td><input type="text" value="" /></td>
</tr>
</table>
或使用>*的直接子进程的边际
table {
border-spacing: 0;
}
td>* {
margin-right: 10px
}<!--border for refrence -->
<table border="1">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td><input type="text" value="" /></td>
<td><input type="text" value="" /></td>
<td><input type="text" value="" /></td>
</tr>
</table>
https://stackoverflow.com/questions/50821653
复制相似问题