html - 表格内每个 tbody 的垂直条

标签 html css html-table pseudo-element

我有一个动态 HTML 页面,其中有一个包含多个“tbody”元素的表格。 现在,我受困于 CSS,因为我需要在每个“tbody”内显示一个垂直条,如所附图片所示。

我怎样才能完成这件事?我尝试使用“tr::after”并创建一个栏,但没有帮助。

这是我的 html:

你能帮我实现这个吗?

<table>
  <tbody class="container">
    <tr>
     <td>Row 1 Column 1</td>
     <td>Row 1 Column 2</td>
    </tr>
    <tr>
      <td>Row 2 Column 1</td>
      <td>Row 2 Column 2</td>
    </tr>
    <tr>
      <td>Row 3</td>
    </tr>			
  </tbody>
  <tbody class="container">
    <tr>
      <td>Row 1 Column 1</td>
      <td>Row 1 Column 2</td>
    </tr>
    <tr>
      <td>Row 2 Column 1</td>
      <td>Row 2 Column 2</td>
    </tr>
    <tr>
      <td>Row 3</td>
    </tr>			
  </tbody>
  <tbody class="container">
    <tr>
      <td>Row 1 Column 1</td>
      <td>Row 1 Column 2</td>
    </tr>
    <tr>
      <td>Row 2 Column 1</td>
      <td>Row 2 Column 2</td>
    </tr>
    <tr>
      <td>Row 3</td>
    </tr>			
  </tbody>
</table>

UI Design

最佳答案

除了@connor 这样做的诀窍:

tbody {
         margin: 10px;
         display: block;
        }

<style>
    table {
        border-collapse: collapse;
    }
    td:first-child {
        border-right: 1px solid #000;
    }
    tbody {
     margin: 10px;
     display: block;
    }
</style>
<table>
	<tbody class="container">
		<tr>
			<td>Row 1 Column 1</td>
			<td>Row 1 Column 2</td>
		</tr>
		<tr>
			<td>Row 2 Column 1</td>
			<td>Row 2 Column 2</td>
		</tr>
		<tr>
			<td>Row 3</td>
		</tr>
	</tbody>
	<tbody class="container">
		<tr>
			<td>Row 1 Column 1</td>
			<td>Row 1 Column 2</td>
		</tr>
		<tr>
			<td>Row 2 Column 1</td>
			<td>Row 2 Column 2</td>
		</tr>
		<tr>
			<td>Row 3</td>
		</tr>
	</tbody>
	<tbody class="container">
		<tr>
			<td>Row 1 Column 1</td>
			<td>Row 1 Column 2</td>
		</tr>
		<tr>
			<td>Row 2 Column 1</td>
			<td>Row 2 Column 2</td>
		</tr>
		<tr>
			<td>Row 3</td>
		</tr>
	</tbody>
</table>

关于html - 表格内每个 tbody 的垂直条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49322433/

相关文章:

asp.net-mvc - ASP.NET MVC 3 : Support for HTML5 multiple file upload?

jquery - jquery 点击事件最合适的 html 标签是什么?

css - 动画 css3 闪烁的星星

javascript - Jhipster Angular 4 额外的 CSS 和 JS

javascript - document.title 函数无法设置它与 php 一起使用

html - 内容定位不起作用

html - 如何在不剪裁的情况下将文本保留在 div 的边界内?

html - 没有 Bootstrap 的响应表

java - 为什么mySQL数据库以小写字母保存字符串?

html - 顶行固定位置时可滚动的表格内容