Angular 6 Material Data Table with Fixed Header and Paginator

前端 未结 6 1362
我在风中等你
我在风中等你 2020-12-18 18:53

How to make the Header of Data Table component fixed to the top, and the Paginator fixed to the bottom?

This is my HTML:

6条回答
  •  天命终不由人
    2020-12-18 19:34

    As per Material 8.1

    1. For the sticky header we need to give a sticky values as shown in many answers here

    2. For the sticky paginator or bottom fixed paginator.

    We can wrap the table inside a div with max-height or height CSS Property and put the paninator outside that div.

    Html Code sample.

     

    CSS

      table {
        width: 100%;
      }
    
      .table-container {
        max-height: calc(100vh - 155px); // or height: calc(100vh - 155px); depending on your need  change
        overflow: auto;
      }
    

提交回复
热议问题