- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
使用 mat-table
在我的 Angular 6 应用程序中,我无法为 mat-header-row
设置背景颜色和 mat-row
正确地在水平滚动上。 CSS 属性仅应用于屏幕的可见部分,一旦向右滚动,则不会分配颜色。
我的表中大约有 30 列,因此肯定需要水平滚动。
我的 CSS 如下:
.mat-toolbar {
font-size: 17px;
font-family: inherit;
background-color: indigo;
max-height: 12vh;
}
.mat-elevation-z8 {
padding: 0px;
}
.mat-table {
overflow: auto;
max-height: 68vh;
min-width: 100%;
}
.mat-header-row {
position: sticky;
top: -.5px;
z-index: 100;
background-color: gainsboro;
font-size: 12px;
min-height: 8vh;
color: #f5f5f5;
padding-top: 3px;
}
.mat-row:nth-child(even) {
background-color: floralwhite;
}
.mat-row:nth-child(odd) {
background-color: gainsboro;
}
.mat-row {
min-height: 8vh;
}
.no-results {
display: flex;
justify-content: center;
padding: 12px;
font-size: 12px;
font-style: italic;
font-family: inherit;
}
.mat-cell {
font-family: inherit;
font-size: 12px;
}
.mat-header-cell {
font-size: 12px;
font-weight: bolder;
}
.mat-cell:nth-child(1),
.mat-header-cell:nth-child(1) {
flex: 0 0 6%;
}
.mat-cell:nth-child(2),
.mat-header-cell:nth-child(2) {
flex: 0 0 9%;
}
.mat-cell:nth-child(3),
.mat-header-cell:nth-child(3) {
flex: 0 0 14%;
}
.mat-cell:nth-child(4),
.mat-header-cell:nth-child(4) {
flex: 0 0 10%;
}
.mat-cell:nth-child(5),
.mat-header-cell:nth-child(5) {
flex: 0 0 10%;
}
.mat-cell:nth-child(6),
.mat-header-cell:nth-child(6) {
flex: 0 0 8%;
}
.mat-cell:nth-child(7),
.mat-header-cell:nth-child(7) {
flex: 0 0 9%;
}
.mat-cell:nth-child(8),
.mat-header-cell:nth-child(8) {
flex: 0 0 8%;
}
.mat-cell:nth-child(9),
.mat-header-cell:nth-child(9) {
flex: 0 0 8%;
}
.mat-cell:nth-child(10),
.mat-header-cell:nth-child(10) {
flex: 0 0 9%;
}
.mat-cell:nth-child(11),
.mat-header-cell:nth-child(11) {
flex: 0 0 8%;
}
.mat-cell:nth-child(12),
.mat-header-cell:nth-child(12) {
flex: 0 0 11%;
}
.mat-cell:nth-child(13),
.mat-header-cell:nth-child(13) {
flex: 0 0 7%;
}
.mat-cell:nth-child(14),
.mat-header-cell:nth-child(14) {
flex: 0 0 11%;
}
.mat-cell:nth-child(15),
.mat-header-cell:nth-child(15) {
flex: 0 0 7%;
}
.mat-cell:nth-child(16),
.mat-header-cell:nth-child(16) {
flex: 0 0 8%;
}
.mat-column-name {
border-right: 1px solid grey;
align-self: stretch;
text-align: center;
}
.mat-column-position {
border-right: 1px solid grey;
align-self: stretch;
text-align: center;
}
.mat-column-weight {
border-right: 1px solid grey;
align-self: stretch;
text-align: center;
}
.mat-column-symbol {
text-align: center;
align-self: stretch;
}
.mat-column-weight {
align-self: stretch;
}
尝试将溢出属性分别设置为 mat-header-row 和 mat-row;它解决了背景颜色,但标题行和数据行可以在不同步的情况下单独滚动。
HTML文件如下:
<div [@routerTransition] class="col-md-12 mat-elevation-z8" class="white-space-pre-line">
<mat-toolbar color="primary">
Project Times Overview Report
<span class="spacer"></span>
<mat-select *ngxPermissionsOnly="['attendance-all-leave-balance-read']" name="year" [(ngModel)]="selectedYear"
class="form-control" type="text" placeholder="Year" required>
<mat-option *ngFor="let year of yearName" [value]="year">{{year}}</mat-option>
</mat-select>
<button class="btn btn-sm btn-primary" *ngxPermissionsOnly="['attendance-all-leave-balance-read']" [disabled]="selectedYear==''"
(click)="loadData()">View Report</button>
</mat-toolbar>
<div class="form">
<mat-form-field floatPlaceholder="never" color="primary">
<input matInput #filter placeholder="Filter">
</mat-form-field>
</div>
<mat-table #table [dataSource]="dataSource" matSort class="mat-cell">
<ng-container matColumnDef="sno">
<mat-header-cell *matHeaderCellDef>S.No.</mat-header-cell>
<mat-cell *matCellDef="let timesReport; let i = index;">{{i+1}}</mat-cell>
</ng-container>
<ng-container matColumnDef="timesCode">
<mat-header-cell *matHeaderCellDef>Times Code</mat-header-cell>
<mat-cell *matCellDef="let timesReport">{{timesReport.timesCode}}</mat-cell>
</ng-container>
<ng-container matColumnDef="projectName">
<mat-header-cell *matHeaderCellDef>Project</mat-header-cell>
<mat-cell *matCellDef="let timesReport">{{timesReport.projectName}}</mat-cell>
</ng-container>
<ng-container matColumnDef="team">
<mat-header-cell *matHeaderCellDef mat-sort-header>Team</mat-header-cell>
<mat-cell *matCellDef="let timesReport">{{getTeamDesc(timesReport)}}</mat-cell>
</ng-container>
<ng-container matColumnDef="department">
<mat-header-cell *matHeaderCellDef mat-sort-header>Department</mat-header-cell>
<mat-cell *matCellDef="let timesReport">{{getDeptDesc(timesReport)}}</mat-cell>
</ng-container>
<ng-container matColumnDef="allocatedWorkload">
<mat-header-cell *matHeaderCellDef mat-sort-header>Allocated PD</mat-header-cell>
<mat-cell *matCellDef="let timesReport">{{timesReport.allocatedWorkload}}</mat-cell>
</ng-container>
<ng-container matColumnDef="activity">
<mat-header-cell *matHeaderCellDef>Activity</mat-header-cell>
<mat-cell *matCellDef="let timesReport">{{timesReport.activity}}</mat-cell>
</ng-container>
<ng-container matColumnDef="actualWorkload">
<mat-header-cell *matHeaderCellDef mat-sort-header>Actual Received PD</mat-header-cell>
<mat-cell *matCellDef="let timesReport">{{timesReport.actualWorkload}}</mat-cell>
</ng-container>
<ng-container matColumnDef="createdBy">
<mat-header-cell *matHeaderCellDef mat-sort-header>Created By</mat-header-cell>
<mat-cell *matCellDef="let timesReport">{{timesReport.createdBy}}</mat-cell>
</ng-container>
<ng-container matColumnDef="creationDate">
<mat-header-cell *matHeaderCellDef mat-sort-header>Creation Date</mat-header-cell>
<mat-cell *matCellDef="let timesReport">{{timesReport.creationDate}}</mat-cell>
</ng-container>
<ng-container matColumnDef="approvedBy">
<mat-header-cell *matHeaderCellDef mat-sort-header>Approved By</mat-header-cell>
<mat-cell *matCellDef="let timesReport">{{timesReport.approvedBy}}</mat-cell>
</ng-container>
<ng-container matColumnDef="approvalDate">
<mat-header-cell *matHeaderCellDef mat-sort-header>Approval Date</mat-header-cell>
<mat-cell *matCellDef="let timesReport">{{timesReport.approvalDate}}</mat-cell>
</ng-container>
<ng-container matColumnDef="claimed">
<mat-header-cell *matHeaderCellDef mat-sort-header>Claimed PD</mat-header-cell>
<mat-cell *matCellDef="let timesReport">{{timesReport.claimed}}</mat-cell>
</ng-container>
<ng-container matColumnDef="unclaimed">
<mat-header-cell *matHeaderCellDef mat-sort-header>Unclaimed PD</mat-header-cell>
<mat-cell *matCellDef="let timesReport">{{timesReport.unclaimed}}</mat-cell>
</ng-container>
<ng-container matColumnDef="gapActualAllocated">
<mat-header-cell *matHeaderCellDef mat-sort-header>Gap (Actual vs Allocated)</mat-header-cell>
<mat-cell *matCellDef="let timesReport">{{timesReport.gapActualAllocated}}</mat-cell>
</ng-container>
<ng-container matColumnDef="lossPD">
<mat-header-cell *matHeaderCellDef mat-sort-header>Loss PD</mat-header-cell>
<mat-cell *matCellDef="let timesReport">{{timesReport.lossPD}}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="dispProjectTimesReportColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: dispProjectTimesReportColumns;"></mat-row>
</mat-table>
<div class="no-results" [style.display]="dataSource.renderedData.length == 0 ? '' : 'none'">
No results found
</div>
<mat-paginator #paginator [length]="dataSource.filteredData.length" [pageIndex]="0" [pageSize]="100"
[pageSizeOptions]="[25, 50, 100, 200]">
</mat-paginator>
</div>
最佳答案
.mat-header-row{
width: fit-content !important;
}
.mat-row{
width: fit-content !important;
}
关于css - 水平滚动上的 Mat-table 背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53812388/
我正在使用 CSS background: url(stuffhere.jpeg)对于我的背景,但是当你点击其他视频时,“元素”不是页面,背景不会改变。 我试过了 和 ,并尝试为#home 和#pr
这两个 CSS 属性有区别吗: background: none; background: transparent; 它们都有效吗? 应该使用哪一个,为什么? 最佳答案 它们之间没有区别。 如果您没有
csslint 警告回退背景(十六进制或 RGB)应该在 RGBA 背景之前。"evidence="background: rgba(0, 0, 0, 0.8);/* FF3+,Saf3+,Opera
我在我正在制作的新网站上使用 Flip 插件: http://www.concept-it.be/padre (点击联系人,然后点击电子邮件地址)。 正如你所看到的,当翻转开始后,div 的背景变成灰
有没有办法使用“前后”图像作为全尺寸背景?我想会很棒!我正在尝试将此类示例用作整页大小的图像; http://www.catchmyfame.com/2009/06/25/jquery-beforea
我认为答案是否定的,但是... 有没有办法说: background-size: contain 90% 所以它的作用正是 contain 会做的,但是然后将它调整得更小一些? 最佳答案 理想的解决方
将鼠标悬停在给定文本的每个字母上将更改文本的整个字体 + 正文背景颜色。我试过了,但我的尝试失败了。相反,字体只在被悬停的字母之后发生变化,我什至不知道如何从 div 选择器中影响正文背景颜色。 .h
我想给我的 UITableView 提供背景图片,所以我尝试了这个方法: - (void)viewDidLoad { [super viewDidLoad]; // Do any additional
我正在尝试使用 Python 3.6 使用 PIL/Numpy(每个屏幕截图~0.01s)快速截取准备处理的屏幕截图。理想情况下,窗口不需要位于前台,即即使另一个窗口覆盖它,屏幕截图仍然成功。 到目前
我正在尝试做一些可能不可能的事情,但让我们看看你怎么想。这是我的代码: html { background: url(../img/pattern.png) repeat, url(../im
一位设计师想出了这种类型的背景,如下图所示。我想避免使用图像背景。因此,如果可以使用 CSS background 属性复制它,我会努力思考。 最底层只是一个线性渐变,没有问题。但是在其之上分层的圆形
当 TreeView(或应用程序)失去焦点时,如何更改所选 TreeViewItem 的背景。在这种情况下,默认情况下选定的项目具有浅灰色背景。 编辑:第一个答案后的尝试:但是找不到带有 Target
一位设计师想出了这种类型的背景,如下图所示。我想避免使用图像背景。因此,如果可以使用 CSS background 属性复制它,我会努力思考。 最底层只是一个线性渐变,没有问题。但是在其之上分层的圆形
我需要有一个带有 CSS 的背景作为附加的图像我不能让它与线性渐变一起工作。 我正在尝试以下操作,但我无法仅创建 1 个白色条纹。 div { background: #5cbcb0; bac
我有一个ListView,它有一个页眉和页脚。它们在 CardView 中的布局。以及其中必须为背景的内容列表。这是一张可以清楚看到的图片:我现在是这样的: 以及如何做: 我这样做了,ScrollVi
我目前有一个 DIV,其背景图像设置如下: background: url(../images/site/common/body-bannar-bkground.png) repeat 0 0; 如何
我有一个 slider ,需要在不使用 .style.backgroundImage 的情况下更改背景。那么我该如何通过向 slider 或其他东西添加一些类来做到这一点呢? 'use strict'
好的,所以在 photoshop 中,我创建了一个具有透明背景和一些文本的 8 位彩色图像。然后我创建了一个具有透明背景和一些文本的 16 位颜色的图像。 当我右键单击两个图像并转到属性时,它显示两个
我有一个问题困扰着我,我似乎在 Google 上找不到答案。我用一段代码创建了一个小型测试应用程序,它执行如下操作: 在 MainActivity 中,我创建了一个 SomeClass 的实例,它有一
我想做这个, 在 Android Studio 的预览中看起来不错,但在运行时我得到这个 正如您在屏幕开头看到的那样,颜色是白色,我想添加我自己的颜色,在本例中为绿色。 最初它使用的是 Cordina
我是一名优秀的程序员,十分优秀!