How can I lock the first row and first column of a table when scrolling, possibly using JavaScript and CSS?

后端 未结 13 2179
攒了一身酷
攒了一身酷 2020-11-27 03:11

How can I create a table that has its first row and first column both locked, as in Excel, when you activate \'freeze panes\'? I need the table to both scroll horizontally

13条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 04:02

    You can do it, without javascript

    see this link: http://yonax73.blogspot.com/2014/09/tabla-con-cabecera-estatica-cuerpo-con.html

    or live demo: http://jsfiddle.net/yonatanalexis22/aeeme8mt/7/

    table{
    border-spacing: 0;
    display: flex;/*Se ajuste dinamicamente al tamano del dispositivo**/
    max-height: 40vh; /*El alto que necesitemos**/
    overflow-y: auto; /**El scroll verticalmente cuando sea necesario*/
    overflow-x: hidden;/*Sin scroll horizontal*/
    table-layout: fixed;/**Forzamos a que las filas tenga el mismo ancho**/
    width: 98vw; /*El ancho que necesitemos*/
    border:1px solid gray;}
    

提交回复
热议问题