防止缩进带有边框折叠的表格,单独的
Preventing indent of tables with border-collapse, separate
我有一些非常基础的html:
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
<table>
<tr>
<th>Addressed to</th>
<th>Sender</th>
<th>Price</th>
<th>Comments</th>
</tr>
<tr>
<td>Joe smith</td>
<td>Ralph Lauren</td>
<td>0</td>
<td>Lorem ipsum dolor sit amer</td>
</tr>
<tr>
<td>Joe smith</td>
<td>Ralph Lauren</td>
<td>0</td>
<td>Lorem ipsum dolor sit amer</td>
</tr>
</table>
<p>It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
现在,我想在 table 行和列之间添加间距,所以我添加了 css:
table {
border-collapse: separate;
border-spacing: 20px 10px;
}
太棒了。除了现在 table 本身不再与 2 个段落齐平。
我的问题是 table 如何获得所需的间距而不是缩进,或者如何应用最少的 CSS 来克服缩进?
查看此代码
要获得快速解决方案(尤其是静态站点),只需将边距缩减 20 像素(与 table 上的缩进相同)
margin-left:-20px;
here 是一个工作示例
而不是使用 border-spacing
,您可以只在 table 上设置边距,然后还为每一行设置填充以实现与文本左对齐相同的效果
table {
border-collapse: separate;
margin-right:20px;
}
td {
padding-top:10px;
}
table {
border-collapse: separate;
margin-right:20px;
}
td {
padding:10px;
}
我有一些非常基础的html:
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
<table>
<tr>
<th>Addressed to</th>
<th>Sender</th>
<th>Price</th>
<th>Comments</th>
</tr>
<tr>
<td>Joe smith</td>
<td>Ralph Lauren</td>
<td>0</td>
<td>Lorem ipsum dolor sit amer</td>
</tr>
<tr>
<td>Joe smith</td>
<td>Ralph Lauren</td>
<td>0</td>
<td>Lorem ipsum dolor sit amer</td>
</tr>
</table>
<p>It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
现在,我想在 table 行和列之间添加间距,所以我添加了 css:
table {
border-collapse: separate;
border-spacing: 20px 10px;
}
太棒了。除了现在 table 本身不再与 2 个段落齐平。
我的问题是 table 如何获得所需的间距而不是缩进,或者如何应用最少的 CSS 来克服缩进?
查看此代码要获得快速解决方案(尤其是静态站点),只需将边距缩减 20 像素(与 table 上的缩进相同)
margin-left:-20px;
here 是一个工作示例
而不是使用 border-spacing
,您可以只在 table 上设置边距,然后还为每一行设置填充以实现与文本左对齐相同的效果
table {
border-collapse: separate;
margin-right:20px;
}
td {
padding-top:10px;
}
table {
border-collapse: separate;
margin-right:20px;
}
td {
padding:10px;
}