【问题标题】:scroll table in both direction with the header fixed only using sass双向滚动表,标题仅使用 sass 固定
【发布时间】:2019-03-02 04:35:27
【问题描述】:

我有一张角桌

     <table class="table">
<thead>
  <tr>
    <td *ngFor="let header of objectKeys(tableContents[0])">{{header}}</td>
  </tr>
</thead>
<tbody>
  <tr *ngFor="let content of tableContents">
    <td *ngFor="let key of objectKeys(content)">{{content[key]}}</td>
  </tr>
</tbody>

我必须根据屏幕调整它们的高度,然后在标题固定的情况下双向滚动,并且屏幕大小将是移动设备的大小。 我尝试使用给定的许多资源,但所有资源都使用了我无法使用的水平滚动的 javascript。 这是我尝试过的..这使标题不可滚动并且还减小了它的宽度。

 .table{
border-collapse: collapse;

thead{

    td{
        padding: 4px;
        background-color: $filter-background;
        color: $white;
    }
    tr,td{
        border: 2px solid $input-border2; 
        padding: 2px;
    }
}
tbody{
height:100px;
display: block;
overflow-y: scroll;
    tr:nth-child(odd){
    background-color: $input-background;
    }
    tr,td{
        border: 2px solid $input-border2; 

    }
    width: 400px;
 }
 display: block;
  overflow-x: auto;
}

【问题讨论】:

    标签: angular html-table sass


    【解决方案1】:

    position: sticky 可能就是您要找的。​​p>

    试试这个:

    thead td {
      position: sticky;
      top: 0;
    }
    

    并删除overflowheight 规则。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-16
      • 1970-01-01
      • 1970-01-01
      • 2012-11-27
      • 2019-12-19
      • 2017-07-23
      • 2012-01-15
      相关资源
      最近更新 更多