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

后端 未结 25 2308
有刺的猬
有刺的猬 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:07

    You can just make the first column position: sticky; z-index: 9. It will make the column/row stick to its current position. Checkout my example codepen here https://codepen.io/swastikmishra/pen/zYYdKBQ

    HTML Example

    
            
    Hello WorldHello WorldHello WorldHello WorldHello WorldHello WorldHello World
    H11H12H13H14H15H16H17
    H21H22H23H24H25H26H27
    H31H32H33H34H35H36H37
    H41H42H44H44H45H46H47
    H51H52H54H54H55H56H57
    H61H62H64H64H65H66H67
    H71H72H74H74H75H76H77
    H81H82H84H84H85H86H87

提交回复
热议问题