168 lines
4.0 KiB
CSS
168 lines
4.0 KiB
CSS
/* 重置所有表格相关样式,确保我们的样式优先级 */
|
||
.scrollable-table-container * {
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
/* 表格容器样式 */
|
||
.scrollable-table-container {
|
||
height: 390px;
|
||
overflow: scroll;
|
||
margin-bottom: 1em;
|
||
border: 1px solid #ddd;
|
||
position: relative;
|
||
background-color: #fff;
|
||
isolation: isolate;
|
||
/* 启用GPU加速 */
|
||
transform: translateZ(0);
|
||
-webkit-transform: translateZ(0);
|
||
}
|
||
|
||
/* 确保表格占据全部宽度 */
|
||
.scrollable-table-container table {
|
||
width: 100%;
|
||
border-collapse: separate;
|
||
border-spacing: 0;
|
||
table-layout: fixed;
|
||
margin: 0;
|
||
}
|
||
|
||
/* 表头单元格样式 - 提高z-index并确保背景色 */
|
||
.scrollable-table-container thead th {
|
||
position: sticky;
|
||
top: 0;
|
||
z-index: 200;
|
||
background-color: #f8f8f8 !important;
|
||
border-bottom: 2px solid #ddd;
|
||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||
padding: 8px 12px;
|
||
text-align: left;
|
||
font-weight: bold;
|
||
/* 启用GPU加速 */
|
||
transform: translateZ(0);
|
||
-webkit-transform: translateZ(0);
|
||
/* 移除will-change,它可能导致性能问题 */
|
||
will-change: auto;
|
||
}
|
||
|
||
/* 表格单元格样式 */
|
||
.scrollable-table-container td {
|
||
padding: 8px 12px;
|
||
text-align: left;
|
||
border: 1px solid #ddd;
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
background-color: #fff;
|
||
position: relative;
|
||
z-index: 1;
|
||
}
|
||
|
||
/* 固定首列样式 - 提高z-index并确保背景色 */
|
||
.scrollable-table-container td:first-child {
|
||
position: sticky;
|
||
left: 0;
|
||
z-index: 150;
|
||
background-color: #fff !important;
|
||
border-right: 2px solid #ddd;
|
||
box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
|
||
min-width: 150px;
|
||
/* 启用GPU加速 */
|
||
transform: translateZ(0);
|
||
-webkit-transform: translateZ(0);
|
||
/* 移除will-change,它可能导致性能问题 */
|
||
will-change: auto;
|
||
}
|
||
|
||
/* 固定表头的首列(左上角单元格) - 最高优先级 */
|
||
.scrollable-table-container thead th:first-child {
|
||
position: sticky;
|
||
left: 0;
|
||
z-index: 250;
|
||
background-color: #f8f8f8 !important;
|
||
box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
|
||
min-width: 150px;
|
||
/* 启用GPU加速 */
|
||
transform: translateZ(0);
|
||
-webkit-transform: translateZ(0);
|
||
/* 移除will-change,它可能导致性能问题 */
|
||
will-change: auto;
|
||
}
|
||
|
||
/* 使用!important确保固定元素的背景色不被覆盖 */
|
||
.scrollable-table-container thead th {
|
||
background-color: #f8f8f8 !important;
|
||
}
|
||
|
||
.scrollable-table-container td:first-child {
|
||
background-color: #fff !important;
|
||
}
|
||
|
||
.scrollable-table-container thead th:first-child {
|
||
background-color: #f8f8f8 !important;
|
||
}
|
||
|
||
/* 响应式调整 */
|
||
@media screen and (max-width: 768px) {
|
||
.scrollable-table-container {
|
||
height: 300px;
|
||
}
|
||
|
||
.scrollable-table-container td:first-child,
|
||
.scrollable-table-container th:first-child {
|
||
min-width: 120px;
|
||
}
|
||
}
|
||
|
||
/* 为表格内容区域添加轻微背景色,增强可读性 */
|
||
.scrollable-table-container tbody tr:nth-child(even) {
|
||
background-color: #f9f9f9;
|
||
}
|
||
|
||
.scrollable-table-container tbody tr:hover {
|
||
background-color: #f0f0f0;
|
||
}
|
||
|
||
/* 针对Chrome的优化 */
|
||
@media screen and (-webkit-min-device-pixel-ratio:0) {
|
||
.scrollable-table-container {
|
||
/* Chrome特定优化 */
|
||
-webkit-backface-visibility: hidden;
|
||
backface-visibility: hidden;
|
||
}
|
||
|
||
.scrollable-table-container thead th,
|
||
.scrollable-table-container td:first-child,
|
||
.scrollable-table-container thead th:first-child {
|
||
/* Chrome特定优化 */
|
||
-webkit-backface-visibility: hidden;
|
||
backface-visibility: hidden;
|
||
}
|
||
}
|
||
|
||
/* 强制滚动条样式 */
|
||
.scrollable-table-container::-webkit-scrollbar {
|
||
height: 12px;
|
||
width: 12px;
|
||
-webkit-appearance: none;
|
||
}
|
||
|
||
.scrollable-table-container::-webkit-scrollbar-track {
|
||
background: #f1f1f1;
|
||
border-radius: 6px;
|
||
}
|
||
|
||
.scrollable-table-container::-webkit-scrollbar-thumb {
|
||
background: #c1c1c1;
|
||
border-radius: 6px;
|
||
border: 2px solid #f1f1f1;
|
||
}
|
||
|
||
.scrollable-table-container::-webkit-scrollbar-thumb:hover {
|
||
background: #a8a8a8;
|
||
}
|
||
|
||
/* 针对Firefox的滚动条样式 */
|
||
.scrollable-table-container {
|
||
scrollbar-width: thin;
|
||
scrollbar-color: #c1c1c1 #f1f1f1;
|
||
} |