如何修复 mat-tab 的标题 [英] How to fix the header of mat-tab

查看:24
本文介绍了如何修复 mat-tab 的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 5 个垫子标签,每个标签都有大量数据,因此滚动被添加到该窗口.有什么方法可以修复 mat-tab 的标题并让内容可以滚动.

我尝试放置位置:固定;和位置:粘在里面

::ng-deep .mat-tab-label {}

但似乎并没有解决问题.我的html

<mat-tab-group class="demo-tab-group" (selectedIndexChange)="loadDynamicContent($event)"><mat-tab matTooltip="工具提示!"标签=个人信息"><table id="customers" *ngIf="customerData"><标题><h4>客户信息</h4></caption><tr *ngFor="let item of customerData"><td class="key" width="50%">{{item.key}}</td><td class="value" width="50%">{{item.value}}</td></tr><table id="customers" *ngIf="aadhaarAddress"><标题><h4>Aadhaar 地址</h4></caption><tr *ngFor="let item of aadhaarAddress"><td class="key" width="50%">{{item.key}}</td><td class="value" width="50%">{{item.value}}</td></tr><table id="customers" *ngIf="presentAddress"><标题><h4>当前地址</h4></caption><tr *ngFor="let item of presentAddress"><td class="key" width="50%">{{item.key}}</td><td class="value" width="50%">{{item.value}}</td></tr><table id="customers" *ngIf="financialInfo"><标题><h4>财务健康信息</h4></caption><tr *ngFor="让金融信息的项目"><td class="key">{{item.key}}</td><td class="value">{{item.value}}</td></tr><br></mat-tab><mat-tab label="A局"><table id="customers" *ngIf="bureauAnalysisData"><标题><h4>局分析数据</h4></caption><tr *ngFor="let 项目的 BureauAnalysisData"><td class="key" width="50%">{{item.key}}</td><td class="value" width="50%">{{item.value}}</td></tr><table id="customers" *ngIf="bureauScoreReasons"><标题><h4>Bureau 评分原因</h4></caption><tr *ngFor="let item of BureauScoreReasons"><td class="key" width="50%">{{item.key}}</td><td class="value" width="50%">{{item.value}}</td></tr><table id="customers" *ngIf="bureauEMI"><标题><h4>CIBIL中的总EMI</h4></caption><tr *ngFor="let item of BureauEMI"><td class="key" width="50%">{{item.key}}</td><td class="value" width="50%">{{item.value}}</td></tr><br></mat-tab><mat-tab label="Bureau E"><table id="customers" *ngIf="en​​quiry1"><标题><h4>过去 30 天内的查询</h4></caption><tr><th class="hide"></th><th class="value hide">查询次数</th><th class="value hide">平均金额</th></tr><tr *ngFor="let item of enquiry1"><td class="key" width="50%">{{item.key}}</td><td class="value" width="25%">{{item.value}} </td><td class="value" width="25%">{{item.value2}}</td></tr><br><table id="customers" *ngIf="en​​quiry2"><标题><h4>过去 31-90 天内的查询</h4></caption><tr><th class="hide"></th><th class="value hide">查询次数</th><th class="value hide">平均金额</th></tr><tr *ngFor="let item of enquiry2"><td class="key" width="50%">{{item.key}}</td><td class="value" width="25%">{{item.value}}</td><td class="value" width="25%">{{item.value2}}</td></tr><br></mat-tab><mat-tab label="SMS"><table id="customers" *ngIf="smsData"><标题><h4>短信数据分析</h4></caption><tr *ngFor="让 smsData 的项目"><td class="key" width="50%">{{item.key}}</td><td class="value" width="50%">{{item.value}}</td></tr><table id="customers" *ngIf="salary"><div *ngIf="salary.lenght>0"><标题><h4>薪水</h4></caption><tr><th width="1%">S.No </th><th width="20%">SMS 日期 </th><th width="13%">发件人姓名</th><th width="66">原始消息 </th></tr><tr *ngFor="let 工资项;let i=index"><td>{{i+1}}</td><td>{{item.smsDate}}</td><td>{{item.senderName}}</td><td>{{item.originalMessage}}</td></tr>

<table id="customers" *ngIf="balance"><div *ngIf="balance.length>0"><标题><h4>不足、退回、退回、逾期</h4></caption><tr><th width="1%">S.No </th><th width="20%">SMS 日期 </th><th width="13%">发件人姓名</th><th width="66">原始消息 </th></tr><tr *ngFor="let item of balance;let i=index"><td>{{i+1}}</td><td>{{item.smsDate}}</td><td>{{item.senderName}}</td><td>{{item.originalMessage}}</td></tr>

<table id="customers" *ngIf="nach"><div *ngIf="nach.length>0"><标题><h4>EMI、ECS&NACH/h4</caption><tr><th width="1%">S.No </th><th width="20%">SMS 日期 </th><th width="13%">发件人姓名</th><th width="66">原始消息 </th></tr><tr *ngFor="let item of nach;let i=index"><td>{{i+1}}</td><td>{{item.smsDate}}</td><td>{{item.senderName}}</td><td>{{item.originalMessage}}</td></tr>

<table id="customers" *ngIf="bureau"><div *ngIf="bureau.length>0"><标题><h4>Bureau</h4></caption><tr><th width="1%">S.No </th><th width="20%">SMS 日期 </th><th width="13%">发件人姓名</th><th width="66">原始消息 </th></tr><tr *ngFor="let item of Bureau;let i=index"><td>{{i+1}}</td><td>{{item.smsDate}}</td><td>{{item.senderName}}</td><td>{{item.originalMessage}}</td></tr>

<table id="customers" *ngIf="companySalary"><div *ngIf="companySalary.length>0"><标题><h4>公司薪资</h4></caption><tr><th width="1%">S.No </th><th width="20%">SMS 日期 </th><th width="13%">发件人姓名</th><th width="66">原始消息 </th></tr><tr *ngFor="let companySalary 的项目;let i=index"><td>{{i+1}}</td><td>{{item.smsDate}}</td><td>{{item.senderName}}</td><td>{{item.originalMessage}}</td></tr>

<table id="customers" *ngIf="loan"><div *ngIf="loan.length>0"><标题><h4>贷款</h4></caption><tr><th width="1%">S.No </th><th width="20%">SMS 日期 </th><th width="13%">发件人姓名</th><th width="66">原始消息 </th></tr><tr *ngFor="let item of贷款;let i=index"><td>{{i+1}}</td><td>{{item.smsDate}}</td><td>{{item.senderName}}</td><td>{{item.originalMessage}}</td></tr>

<table id="customers" *ngIf="score"><div *ngIf="score.length>0"><标题><h4>分数</h4></caption><tr><th width="1%">S.No </th><th width="20%">SMS 日期 </th><th width="13%">发件人姓名</th><th width="66">原始消息 </th></tr><tr *ngFor="let item of score;let i=index"><td>{{i+1}}</td><td>{{item.smsDate}}</td><td>{{item.senderName}}</td><td>{{item.originalMessage}}</td></tr>

<table id="customers" *ngIf="allSMSData"><div *ngIf="allSMSData.length>0"><标题><h4>所有短信</h4></caption><tr><th width="1%">S.No </th><th width="20%">SMS 日期 </th><th width="13%">发件人姓名</th><th width="66">原始消息 </th></tr><tr *ngFor="let item of allSMSData;let i=index"><td >{{i+1}}</td><td >{{item.smsDate}}</td><td>{{item.senderName}}</td><td >{{item.originalMessage}}</td></tr>

<br></mat-tab><mat-tab label="设备"><table id="customers" *ngIf="deviceData"><标题><h4>设备数据</h4></caption><tr *ngFor="let item of deviceData"><td class="key" width="50%">{{item.key}}</td><td class="value" width="50%">{{item.value}}</td></tr><table id="customers" *ngIf="wifiConnectionInfo"><caption *ngIf="wifiConnectionInfo.length>0"><h4>Wi-Fi 连接信息</h4></caption><tr *ngIf="wifiConnectionInfo.length>0"><th style="padding-left: 75px ">Wi-Fi Name</th><th style="padding-left: 75px; ">No.过去 7 天内连接的次数</tr><tr *ngFor="let wifiConnectionInfo 项"><td class="key" width="50%">{{item.key}}</td><td class="value" width="50%">{{item.value}}</td></tr><br><table id="customers" *ngIf="accountInfo"><caption *ngIf="accountInfo.length>0"><h4>账户信息</h4></caption><tr><th style="padding-left: 75px">电子邮件</th><th style="padding-left: 75px;">供应商</th></tr><tr *ngFor="let item of accountInfo"><td class="key" width="50%">{{item.email}}</td><td class="value" width="50%">{{item.vendor}}</td></tr><br></mat-tab><mat-tab label="Json"><垫卡><app-ngx-json-viewer [json]="bureauJSON"></app-ngx-json-viewer></mat-card></mat-tab></mat-tab-group>

css

mat-grid-tile {背景:浅灰色;}h4{颜色:灰色;文本对齐:居中;}.钥匙 {padding-left: 75px !important;字体粗细:粗体;颜色:灰色;}.无法使用 {保证金最高:15%;文本对齐:居中;字体大小:14px;}.mat-tab-body-content {高度:100%;}.价值 {padding-left: 75px !important;颜色:灰色;}::ng-deep .mat-tab-labels {对齐内容:居中;填充:0px 7px !重要;字体大小:10px !重要;}::ng-deep .mat-tab-label {对齐内容:居中;填充:0px 7px !重要;字体大小:12px !重要;最小宽度:85px!重要;}.隐藏 {边界:无!重要;}#顾客 {填充:0;保证金:0;font-family: 'Roboto', 'Helvetica Neue', sans-serif;字体大小:12px;字体粗细:500;宽度:100%;边框折叠:折叠;}TD{颜色:#808080;}.容器 {溢出-y:自动;}#customers td,#customers th {边框:1px 实心#ddd;填充:2px;}#customers tr:nth-child(even) {背景色:#f2f2f2;}#customers th {颜色:灰色;文本对齐:左;边框折叠:折叠;}

解决方案

使用 position: fixed !important; inside

解决

:host ::ng-deep .mat-tab-header {}

但是该选项卡不可点击,因此添加了 z-index:100000; 然后它开始工作.

I am having 5 mat-tab and each tab is having a large amount of data so scroll is getting added to that window. Is there any way through which I can fix the header of mat-tab and let the content to be scroll able.

I tried putting position:fixed; and position:sticky inside

::ng-deep .mat-tab-label {

}

But it do not seems to solve the problem. my html

<div class="container">

  <mat-tab-group class="demo-tab-group" (selectedIndexChange)="loadDynamicContent($event)">
    <mat-tab matTooltip="Tooltip!" label="Pers info">
      <table id="customers" *ngIf="customerData">
        <caption>
          <h4>Customer Information</h4>
        </caption>
        <tr *ngFor="let item of customerData">
          <td class="key" width="50%">
            {{item.key}}
          </td>
          <td class="value" width="50%">{{item.value}}</td>
        </tr>
      </table>
      <table id="customers" *ngIf="aadhaarAddress">
        <caption>
          <h4>Aadhaar Address</h4>
        </caption>
        <tr *ngFor="let item of aadhaarAddress">
          <td class="key" width="50%">
            {{item.key}}
          </td>
          <td class="value" width="50%">{{item.value}}</td>
        </tr>
      </table>
      <table id="customers" *ngIf="presentAddress">
        <caption>
          <h4>Present Address</h4>
        </caption>
        <tr *ngFor="let item of presentAddress">
          <td class="key" width="50%">
            {{item.key}}
          </td>
          <td class="value" width="50%">{{item.value}}</td>
        </tr>
      </table>
      <table id="customers" *ngIf="financialInfo">
        <caption>
          <h4>Financial Health Information</h4>
        </caption>
        <tr *ngFor="let item of financialInfo">
          <td class="key">
            {{item.key}}
          </td>
          <td class="value">{{item.value}}</td>
        </tr>
      </table>
      <br>
    </mat-tab>
    <mat-tab label="Bureau A">
      <table id="customers" *ngIf="bureauAnalysisData">
        <caption>
          <h4>Bureau Analysis Data</h4>
        </caption>
        <tr *ngFor="let item of bureauAnalysisData">
          <td class="key" width="50%">
            {{item.key}}
          </td>
          <td class="value" width="50%">{{item.value}}</td>
        </tr>
      </table>

<table id="customers" *ngIf="bureauScoreReasons">
  <caption>
    <h4>Bureau Score Reasons</h4>
  </caption>
<tr *ngFor="let item of bureauScoreReasons">

    <td class="key" width="50%">

      {{item.key}}
    </td>
    <td class="value" width="50%">{{item.value}}</td>

  </tr>
</table>

      <table id="customers" *ngIf="bureauEMI">
        <caption>
          <h4>Total EMI in CIBIL</h4>
        </caption>
        <tr *ngFor="let item of bureauEMI">
<td class="key" width="50%">

            {{item.key}}
          </td>
<td class="value" width="50%">{{item.value}}</td>

        </tr>
      </table>
      <br>
    </mat-tab>
    <mat-tab label="Bureau E">
      <table id="customers" *ngIf="enquiry1">
        <caption>
          <h4>Enquiries in last 30 days</h4>
        </caption>
        <tr>
          <th class="hide"></th>
          <th class="value hide">Number of enquiries</th>
          <th class="value hide">Average amount</th>
        </tr>
        <tr *ngFor="let item of enquiry1">
          <td class="key" width="50%">
            {{item.key}}
          </td>
          <td class="value" width="25%">{{item.value}} </td>
          <td class="value" width="25%">{{item.value2}}</td>
        </tr>
      </table>
      <br>
      <table id="customers" *ngIf="enquiry2">
        <caption>
          <h4>Enquiries in last 31-90 days</h4>
        </caption>
        <tr>
          <th class="hide"></th>
          <th class="value hide">Number of enquiries</th>
          <th class="value hide">Average amount</th>
        </tr>
        <tr *ngFor="let item of enquiry2">
          <td class="key" width="50%">
            {{item.key}}
          </td>
          <td class="value" width="25%">{{item.value}}</td>
          <td class="value" width="25%">{{item.value2}}</td>
        </tr>
      </table>
      <br>
    </mat-tab>
    <mat-tab label="SMS">
      <table id="customers" *ngIf="smsData">
        <caption>
          <h4>SMS Data Analysis</h4>
        </caption>
        <tr *ngFor="let item of smsData">
          <td class="key" width="50%">
            {{item.key}}
          </td>
          <td class="value" width="50%">{{item.value}}</td>
        </tr>
      </table>
      <table id="customers" *ngIf="salary">
        <div *ngIf="salary.lenght>0">
          <caption>
            <h4>Salary</h4>
          </caption>
          <tr>
        <th width="1%">S.No </th>
        <th width="20%">SMS Date </th>
        <th width="13%">Sender Name </th>
        <th width="66">Original Message </th>
          </tr>
          <tr *ngFor="let item of salary;let i=index">
            <td>
              {{i+1}}
            </td>
            <td>{{item.smsDate}}</td>
            <td>{{item.senderName}}</td>
            <td>{{item.originalMessage}}</td>
          </tr>
        </div>
      </table>
      <table id="customers" *ngIf="balance">
        <div *ngIf="balance.length>0">
          <caption>
            <h4>Insufficient, bounce, return, overdue</h4>
          </caption>
          <tr>
        <th width="1%">S.No </th>
        <th width="20%">SMS Date </th>
        <th width="13%">Sender Name </th>
        <th width="66">Original Message </th>
          </tr>
          <tr *ngFor="let item of balance;let i=index">
            <td>
              {{i+1}}
            </td>
            <td>{{item.smsDate}}</td>
            <td>{{item.senderName}}</td>
            <td>{{item.originalMessage}}</td>
          </tr>
        </div>
      </table>
      <table id="customers" *ngIf="nach">
        <div *ngIf="nach.length>0">
          <caption>
            <h4>EMI, ECS & NACH</h4>
          </caption>
          <tr>
          <th width="1%">S.No </th>
          <th width="20%">SMS Date </th>
          <th width="13%">Sender Name </th>
          <th width="66">Original Message </th>
          </tr>
          <tr *ngFor="let item of nach;let i=index">
            <td>
              {{i+1}}
            </td>
            <td>{{item.smsDate}}</td>
            <td>{{item.senderName}}</td>
            <td>{{item.originalMessage}}</td>
          </tr>
        </div>
      </table>
      <table id="customers" *ngIf="bureau">
        <div *ngIf="bureau.length>0">
          <caption>
            <h4>Bureau</h4>
          </caption>
          <tr>
          <th width="1%">S.No </th>
          <th width="20%">SMS Date </th>
          <th width="13%">Sender Name </th>
          <th width="66">Original Message </th>
          </tr>
          <tr *ngFor="let item of bureau;let i=index">
            <td>
              {{i+1}}
            </td>
            <td>{{item.smsDate}}</td>
            <td>{{item.senderName}}</td>
            <td>{{item.originalMessage}}</td>
          </tr>
        </div>
      </table>
      <table id="customers" *ngIf="companySalary">
        <div *ngIf="companySalary.length>0">
          <caption>
            <h4>Company Salary</h4>
          </caption>
          <tr>
        <th width="1%">S.No </th>
        <th width="20%">SMS Date </th>
        <th width="13%">Sender Name </th>
        <th width="66">Original Message </th>
          </tr>
          <tr *ngFor="let item of companySalary;let i=index">
            <td>
              {{i+1}}
            </td>
            <td>{{item.smsDate}}</td>
            <td>{{item.senderName}}</td>
            <td>{{item.originalMessage}}</td>
          </tr>
        </div>
      </table>
      <table id="customers" *ngIf="loan">
        <div *ngIf="loan.length>0">
          <caption>
            <h4>Loan</h4>
          </caption>
          <tr>
        <th width="1%">S.No </th>
        <th width="20%">SMS Date </th>
        <th width="13%">Sender Name </th>
        <th width="66">Original Message </th>
          </tr>
          <tr *ngFor="let item of loan;let i=index">
            <td>{{i+1}}</td>
            <td>{{item.smsDate}}</td>
            <td>{{item.senderName}}</td>
            <td>{{item.originalMessage}}</td>
          </tr>
        </div>
      </table>
      <table id="customers" *ngIf="score">
        <div *ngIf="score.length>0">
          <caption>
            <h4>Score</h4>
          </caption>
          <tr>
        <th width="1%">S.No </th>
        <th width="20%">SMS Date </th>
        <th width="13%">Sender Name </th>
        <th width="66">Original Message </th>
          </tr>
          <tr *ngFor="let item of score;let i=index">
            <td>{{i+1}}</td>
            <td>{{item.smsDate}}</td>
            <td>{{item.senderName}}</td>
            <td>{{item.originalMessage}}</td>
          </tr>
        </div>
      </table>
      <table id="customers" *ngIf="allSMSData">
        <div *ngIf="allSMSData.length>0">
          <caption>
            <h4>All SMS</h4>
          </caption>
          <tr>
            <th width="1%">S.No </th>
            <th width="20%">SMS Date </th>
            <th width="13%">Sender Name </th>
            <th width="66">Original Message </th>
          </tr>
          <tr *ngFor="let item of allSMSData;let i=index">
            <td >{{i+1}}</td>
            <td >{{item.smsDate}}</td>
            <td>{{item.senderName}}</td>
            <td >{{item.originalMessage}}</td>
          </tr>
        </div>
      </table>
      <br>
    </mat-tab>
    <mat-tab label="Device">
      <table id="customers" *ngIf="deviceData">
        <caption>
          <h4>Device Data</h4>
        </caption>
        <tr *ngFor="let item of deviceData">
          <td class="key" width="50%">
            {{item.key}}
          </td>
          <td class="value" width="50%">{{item.value}}</td>
        </tr>
      </table>
      <table id="customers" *ngIf="wifiConnectionInfo">
        <caption *ngIf="wifiConnectionInfo.length>0">
          <h4>Wi-Fi Connections Information</h4>
        </caption>
        <tr *ngIf="wifiConnectionInfo.length>0">
          <th style="padding-left: 75px ">Wi-Fi Name</th>
          <th style="padding-left: 75px; ">No. of times connected in the last 7 days</th>
        </tr>
        <tr *ngFor="let item of wifiConnectionInfo">
          <td class="key" width="50%">
            {{item.key}}
          </td>
          <td class="value" width="50%">{{item.value}}</td>
        </tr>
      </table>
      <br>
      <table id="customers" *ngIf="accountInfo">
        <caption *ngIf="accountInfo.length>0">
          <h4>Account Information</h4>
        </caption>
        <tr>
          <th style="padding-left: 75px">Email</th>
          <th style="padding-left: 75px;">Vendor</th>
        </tr>
        <tr *ngFor="let item of accountInfo">
          <td class="key" width="50%">
            {{item.email}}
          </td>
          <td class="value" width="50%">{{item.vendor}}</td>
        </tr>
      </table>
      <br>
    </mat-tab>
    <mat-tab label="Json">
      <mat-card>
        <app-ngx-json-viewer [json]="bureauJSON"></app-ngx-json-viewer>
      </mat-card>
    </mat-tab>
  </mat-tab-group>
</div>

css

mat-grid-tile {
  background: lightgrey;
}



h4 {
  color: grey;
  text-align: center;
}

.key {
  padding-left: 75px !important;
  font-weight: bold;
  color: gray;
}

.not-available {
  margin-top: 15%;
 text-align: center;
  font-size: 14px;
}

.mat-tab-body-content {
  height: 100%;
}


.value {
  padding-left: 75px !important;
  color: gray;
}

::ng-deep .mat-tab-labels {
   justify-content: center;
   padding: 0px 7px !important;
   font-size: 10px !important;
}

::ng-deep .mat-tab-label {
  justify-content: center;
  padding: 0px 7px !important;
  font-size: 12px !important;
  min-width: 85px !important;

}




.hide {
  border: none !important;
}

#customers {
  padding:0;
  margin:0;
  font-family: 'Roboto', 'Helvetica Neue', sans-serif;
  font-size: 12px;
  font-weight: 500;
  width: 100%;
  border-collapse: collapse;

}

td {
  color: #808080;
}

.container {
  overflow-y: auto;

}

#customers td,
#customers th {
  border: 1px solid #ddd;
  padding: 2px;
}

#customers tr:nth-child(even) {
  background-color: #f2f2f2;
}

#customers th {
  color: gray;
  text-align: left;
  border-collapse: collapse;
}

解决方案

Solved it using position: fixed !important; inside

:host ::ng-deep .mat-tab-header {
}

But then the tab was not clickable so added z-index:100000; and then it starts working.

这篇关于如何修复 mat-tab 的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆