所以我有一个粘性的表格,但我只需要第二列上的方框阴影,即右边的Requestor Name,我想移除我在下面的屏幕显示上放的箭头的阴影,因为第一列和第二列都是粘性的,最后一列也是粘性的,但它看起来很糟糕,那么Requestor Name列的左侧和右侧都有方框阴影.

我们该怎么做呢?谢谢.

table

#html代码

 <table
                          mat-table
                          [dataSource]="dataSource"
                          matMultiSort
                          (matSortChange)="requestsListTable.onSortEvent()"                        >

                        <ng-container matColumnDef="requestTitle" sticky>
                          <th mat-multi-sort-header="requestTitle" mat-header-cell *matHeaderCellDef>Request Title</th>
                          <td mat-cell *matCellDef="let element">
                            <div class="checkbox-container td-value-name">
                              <mat-checkbox [checked]="selectedWorkFlowIds.includes(element.workflowApprovalId)" [disabled]="!isAllowedBulkUpdate(element)" class="no-navigation" color="primary" (change)="onChangeSelect(element, $event, 'request')"></mat-checkbox> 
                              <div [matTooltip]="element.requestTitle" class="td-value-name">{{ element.requestTitle?.length > 45 ? element.requestTitle.slice(0,45) + '...' : element.requestTitle }}</div>
                            </div>
                          </td>
                        </ng-container>

                        <ng-container matColumnDef="requestorName">
                          <th mat-multi-sort-header="requestorName" mat-header-cell *matHeaderCellDef>Requestor Name</th>
                          <td mat-cell *matCellDef="let element">
                            <div class="td-value-name">
                              {{element.requestorName}}
                            </div>
                          </td>
                        </ng-container>

                        <ng-container matColumnDef="requestTypeName">
                          <th mat-multi-sort-header="requestTypeName"  mat-header-cell *matHeaderCellDef>Request Type</th>
                          <td mat-cell *matCellDef="let element" >
                            <div class="td-value-name">
                              {{element.requestTypeName }}
                            </div>
                          </td>
                        </ng-container>

                        <ng-container matColumnDef="department">
                          <th mat-multi-sort-header="department" mat-header-cell *matHeaderCellDef>Department</th>
                          <td mat-cell *matCellDef="let element" >
                            <div class="td-value-name">
                              {{element.departmentName}}
                            </div>
                          </td>
                        </ng-container>

                          <ng-container matColumnDef="requestorPriority">
                            <th mat-multi-sort-header="requestorPriority" mat-header-cell *matHeaderCellDef>Requestor Priority</th>
                            <td mat-cell *matCellDef="let element" >
                              <div class="td-value-name">
                                {{element.requestorPriorityString}}
                              </div>
                            </td>
                          </ng-container>
                  
                          <ng-container matColumnDef="projectTeamPriority">
                            <th mat-multi-sort-header="projectTeamPriority" mat-header-cell *matHeaderCellDef>Project Team Data</th>
                            <td mat-cell *matCellDef="let element">
                              <div class="td-value-name">
                                {{element.projectTeamPriority}}
                              </div>
                            </td>
                          </ng-container>
                  
                          <ng-container matColumnDef="requestDate">
                            <th mat-multi-sort-header="requestDate" mat-header-cell *matHeaderCellDef>Request Date</th>
                            <td mat-cell *matCellDef="let element">
                              <div class="td-value-name">
                                {{element.requestDate | date : 'MM/dd/yyyy'}}
                              </div>
                            </td>
                          </ng-container>
                  
                          <ng-container matColumnDef="targetCompletionDate">
                            <th mat-multi-sort-header="targetCompletionDate" mat-header-cell *matHeaderCellDef>Target Completion Date</th>
                            <td mat-cell *matCellDef="let element">
                              <div class="td-value-name">
                                {{element.targetCompletionDate | date : 'MM/dd/yyyy'}}
                              </div>
                            </td>
                          </ng-container>
                          <ng-container matColumnDef="currentStepName">
                            <th mat-multi-sort-header="currentStepName" mat-header-cell *matHeaderCellDef>Current Step Name</th>
                            <td mat-cell *matCellDef="let element" class="align-icon-and-value">
                              <div class="td-value-name current-step-container">
                                <button mat-button (click)="onViewWorkflow($event, element)">
                                  <mat-icon style="padding-right: 10px;">remove_red_eye</mat-icon> {{element.currentStepName}}
                                </button>
                              </div>
                            </td>
                          </ng-container>
                          <ng-container matColumnDef="currentApprover">
                            <th mat-multi-sort-header="currentApprover" mat-header-cell *matHeaderCellDef>Current Approver</th>
                            <td mat-cell *matCellDef="let element">
                              <div class="td-value-name" [matTooltip]="element.currentApproverName">
                                {{ element.currentApproverName?.length > 45 ? element.currentApproverName.slice(0,45) + '...' : element.currentApproverName }}
                              </div>
                            </td>
                          </ng-container>
                          <ng-container matColumnDef="lastStepCompleted">
                            <th mat-multi-sort-header="lastStepCompleted" mat-header-cell *matHeaderCellDef>
                              Last Step Completed
                            </th>
                            <td mat-cell *matCellDef="let element">
                              <div class="td-value-name">
                                {{ element.lastStepCompleted }}
                              </div>
                            </td>
                          </ng-container>

                          <ng-container matColumnDef="onHold">
                            <th mat-header-cell *matHeaderCellDef class="text-center">On Hold</th>
                            <td mat-cell *matCellDef="let element">
                              <div class="text-center">
                                <!-- <mat-icon class="dragCursor" (mousedown)="dragDisabled = false;"
                                  style="color: rgb(146, 146, 146)">drag_indicator</mat-icon> -->
                                <mat-checkbox [disabled]="!isProjectTeamData" class="no-navigation" color="primary"(change)="onChangeSelect(element, $event, 'OnHold')"
                                [checked]="element.isOnHold"></mat-checkbox>
                              </div>
                            </td>
                          </ng-container>
                      
                          <ng-container matColumnDef="status">
                            <th mat-multi-sort-header="status" mat-header-cell *matHeaderCellDef>Status</th>
                            <td mat-cell *matCellDef="let element">
                              <div>
                                {{ element.statusDisplayString }}
                              </div>
                            </td>
                          </ng-container>

                          <ng-container matColumnDef="actions" stickyEnd > 
                            <th mat-header-cell *matHeaderCellDef class="text-center">Actions</th>
                            <td mat-cell *matCellDef="let element" class="text-center">
                              <div class="action-value-name">
                                <div style="display: flex">
                                  <div (click)="approve($event,element)" *ngIf="element.approveButton && isActionAllowed(element)" class="action-item with-divider text-center">
                                    <mat-icon style="color: #65B741;">check</mat-icon>{{element.approveButton}}
                                  </div>  
                                  <div (click)="reject($event,element)" *ngIf="element.rejectButton && isActionAllowed(element)" class="action-item">
                                    <mat-icon style="color: #DF2E38;">close</mat-icon>{{element.rejectButton}}
                                  </div>
                                </div>
                              </div>
                            </td>
                          </ng-container>
                         
                          <tr mat-header-row *matHeaderRowDef="displayedColumnsTableLeft"></tr>
                          <tr mat-row (click)="viewDetails($event, row)" *matRowDef="let row; columns: displayedColumnsTableLeft"></tr>
                        </table>

#css代码片段

.text-center {
    text-align: center
}

.cursor-pointer {
    cursor: pointer;
}

.sort-button {
    margin-left: 10px;
}

.search-approval {
    width: 300px;
    margin-right: 10px;
    margin-top: -2px;
}

.center-message {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.no-record {
    margin-top: -60px;
    font-size: 12px;
}

.checkbox-container {
    display: flex;
    align-items: center;
}

.mat-checkbox {
    margin-right: 10px;
    /* Adjust the margin as needed */
}

/* .mat-column-requestorName {
    position: sticky;
    left: 200px;
    z-index: 1;
    background-color: inherit;
} */

/* 
.mat-table-sticky-border-elem-right {
    border-left: 1px solid #e0e0e0;
}

.mat-table-sticky-border-elem-left {
    border-right: 1px solid #e0e0e0;
}

th.mat-column-actions,
td.mat-column-actions {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

th.mat-column-requestTypeName,
td.mat-column-requestTypeName {
    padding-left: 12px;
}

th.mat-column-requestTitle,
td.mat-column-requestTitle {
    padding-right: 12px;
}

th.mat-column-requestorName,
td.mat-column-requestorName {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
 */

th.mat-column-actions,
td.mat-column-actions {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.mat-column-requestorName {
    position: sticky;
    left: 200px;
    z-index: 1;
    background-color: inherit;
    /* border-right: 1px solid #e0e0e0; */

}

.mat-column-requestTitle     {
    background-color: inherit;
    /* border-right: 1px solid #e0e0e0; */

}

th.mat-column-requestorName,
td.mat-column-requestorName {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

th.mat-column-requestTypeName,
td.mat-column-requestTypeName {
    padding-left: 12px;
}

推荐答案

请浏览一下css,我们需要指定您需要阴影到哪个索引才能显示,这将帮助您了解它是如何工作的,我们使用nth-child(2)来 Select 第二个子项thtd,我们可以使用:last-child来 Select 最后的thtd,这将启用阴影!

.shaded-table thead tr > th:nth-child(2) {
  box-shadow: 2px 0px 3px #aaaaaa;
}

.shaded-table tbody tr > td:nth-child(2) {
  box-shadow: 2px 0px 3px #aaaaaa;
}

.shaded-table thead tr > th:last-child {
  box-shadow: -2px 0px 3px #aaa;
}

.shaded-table tbody tr > td:last-child {
  box-shadow: -2px 0px 3px #aaa;
}

stackblitz

Javascript相关问答推荐

在React中获取数据后,如何避免不必要的组件闪现1秒?

在JavaScript中声明自定义内置元素不起作用

Chrome是否忽略WebAuthentication userVerification设置?""

给定一个凸多边形作为一组边,如何根据到最近边的距离填充里面的区域

MathJax可以导入本地HTML文档使用的JS文件吗?

如何在Vue 3中创建自定义 Select 组件,并将选项作为HTML而不是props 传递?

如何从HTML对话框中检索单选项组的值?

在forEach循环中获取目标而不是父对象的属性

TypeError:无法分解';React2.useContext(...)';的属性';basename';,因为它为空

如何限制显示在分页中的可见页面的数量

使用jQuery find()获取元素的属性

递增/递减按钮React.js/Redux

REACT-本机错误:错误类型错误:无法读取未定义的容器的属性

相对于具有选定类的不同SVG组放置自定义工具提示

Reaction路由v6.4+数据API:重试加载程序而不显示错误

使用Java脚本筛选数组中最接近值最小的所有项

如果未定义,如何添加全局变量

用内嵌的含selenium的Java脚本抓取网站

在不使用AJAX的情况下将JavaScript数组值传递给Laravel控制器?

Select 所有输入.值