How do I create an HTML table with a fixed/frozen left column and a scrollable body?

后端 未结 25 1537
有刺的猬
有刺的猬 2020-11-21 22:27

I need a simple solution. I know it\'s similar to some other questions, like:

  • HTML table with fixed headers and a fixed column?
  • How can I lock the fir
25条回答
  •  被撕碎了的回忆
    2020-11-21 23:12

    I just made the right-most sticky column of a table sticky.

    th:last-of-type {
     position: sticky;
     right: 0;
     width: 120px;
     background: #f7f7f7;
    }
    
    
    td:last-of-type {
     position: sticky;
     right: 0;
     background: #f7f7f7;
     width: 120px;
    }
    

    I believe if you'll do {position: sticky; left: 0;}, you'll get the desired result.

提交回复
热议问题