【问题标题】:fixing Header of table and making table body scrollale修复表头并使表体可滚动
【发布时间】:2020-05-16 00:31:51
【问题描述】:

我在 Angular 项目中工作,但遇到了设计问题

我想滚动表格主体制作主体标题固定

我尝试执行 at 但无法仅滚动表格正文

我的代码和设计已经准备好了,我已经把它放在下面的链接中 -

https://stackblitz.com/edit/angular-x8c89j?file=src%2Fapp%2Fapp.component.html

【问题讨论】:

标签: html css angular html-table


【解决方案1】:

请更新您的表格样式如下

table {
  width: 100%;
}

table, td {
  border-collapse: collapse;
  border: 1px solid #000;
}

thead {
  display: table; 
  width: calc(100% - 17px); 
}

tbody {
  display: block; 
  max-height: 200px; 
  overflow-y: scroll;
}

th, td {
  padding: 5px;
  word-break: break-all; 
}

tr {
  display: table; 
  width: 100%;
  box-sizing: border-box; 
}

td {
  text-align: center;
  border-bottom: none;
  border-left: none;
}

tr th:first-child,
tr td:first-child {
  width: 100px;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-04
    • 2023-03-29
    • 2019-06-12
    • 1970-01-01
    相关资源
    最近更新 更多