html - 表格边框底部的间距

标签 html css

我有一个表格,我正在使用 CSS 来显示底部边框。

.inset {
    border-bottom: 1px solid #dadce0;
}

我希望左右两侧有一些空间,就像使用 <hr align="center" width="80%"> 一样但我根本不觉得这是可能的。

是否有任何我应该查看的属性或我应该研究的 CSS 技巧以保持表格完好无损并能够看到居中但仅占表格宽度 80% 的底部边框?

最佳答案

您可以将表格宽度设置为 80%(左右边距各留 10%),然后使整个表格居中:

.inset {
  border-bottom: 1px solid #dadce0;
  width: 80%;
  margin: 0 auto;
  background-color: coral;
}

.inset td {
  text-align: center;
}
<table class="inset">
  <tr>
    <td>Row 1 - Cell 1</td>
    <td>Row 1 - Cell 2</td>
    <td>Row 1 - Cell 3</td>
  </tr>
  <tr>
    <td>Row 2 - Cell 1</td>
    <td>Row 2 - Cell 2</td>
    <td>Row 2 - Cell 3</td>
  </tr>
  <tr>
    <td>Row 3 - Cell 1</td>
    <td>Row 3 - Cell 2</td>
    <td>Row 3 - Cell 3</td>
  </tr>
</table>

关于html - 表格边框底部的间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53290697/

相关文章:

javascript - jQuery - 如何将函数(悬停时)绑定(bind)到元素一次?

html - 有什么方法可以在 Twitter 上重现 CSS 折 Angular 效果吗?

javascript - 带百分比的 SVG 进度圈

javascript - div 元素的响应高度

html - Bootstrap Accordion 按钮切换 "data-parent"不工作

javascript - jQuery - 选中的复选框值(链接 jQuery 函数与 If 语句)

php - 典型的 PHP 错误

css - 我将如何进行旋转砌体布局,其中高度恒定且宽度可变

CSS - 背景图像定位

css - 在 Wordpress 中的文本区域自定义字段的各个元素中编辑 css