css实现table最后两列固定
实现方法: postion:sticky(粘性定位)
table {
width: 100%;
border-collapse: separate;
border-spacing: 0;
border: 1px solid #DDDDDD;
}
thead tr th {
position: sticky;
top: 0;
background: #F4F4F5;
height: 30px;
}
th:last-child,
th:nth-last-child(2),
td:last-child,
td:nth-last-child(2) {
position: sticky;
left: 0;
background: #F4F4F5;
text-align: center;
right: 0px;
border-left: 1px solid #DDDDDD;
}
th:nth-last-child(2),
td:nth-last-child(2) {
right: 238px;
th:last-child,
th:nth-last-child(2) {
z-index: 3;
}