HTML:如何: “Separate table rows with a vertical line”

标签 html css

我有一个包含表格行的基本 HTML 表格。我的目标是用可见的垂直线分隔这些表格行(为了更好地阅读内容)。

我该怎么做?谢谢。

JSFIDDLE

.line {
    border-bottom:1px solid black;
}

.textRotation {
    -webkit-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    -ms-transform: rotate(-90deg);
    -o-transform: rotate(-90deg);
    transform: rotate(-90deg);
  ;
}

预期结果: enter image description here

最佳答案

这里有两件事要做:

  1. border-right 应用于 .textRotation 以获得完整的垂直线。
  2. 仅在包含数据的行中的 th 处添加一点填充,这样文本就不会被挤压到该行。

实际数据行在第 4 个 tr 中以“Lun”开始,一直到表的底部,因此您需要使用 :nth-child n+4 的 CSS 选择器并对其应用 padding-left

.textRotation {
    -webkit-transform: rotate(-90deg);
    -moz-transform: rotate(-90deg);
    -ms-transform: rotate(-90deg);
    -o-transform: rotate(-90deg);
    transform: rotate(-90deg);
    border-right: 2px solid black;
}

tr:nth-of-type(n+4) th
{
    padding-left:3px;
}

Updated Fiddle

关于HTML:如何: “Separate table rows with a vertical line”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27702514/

相关文章:

css - 为什么 CSS 相邻组合器在这里不起作用?

jQuery - 如何获取数据名称?

javascript - 显示推文内容时,innerHTML 不起作用

html - 如何仅在某些页面上隐藏我的左侧导航菜单

javascript - 如何隐藏状态栏中的URL加载?

php - Wkhtmltopdf 中的分页符

ios - iOS 上的水平滚动——关闭 Canvas 导航菜单

javascript - 使用 jquery 更改悬停时的背景颜色

html - 图像按钮在表格单元格内不可见

html - 在响应式设计中移动整个 TD?