Set maximum displayed rows count for HTML table

后端 未结 6 1678
情歌与酒
情歌与酒 2021-02-13 22:37

Have JSP page with dynamically generated HTML table with unknown number of rows.

Have property on backend, that sets maximum number of rows, e.g: max_rows=15

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-13 23:17

    Put your table in a div block and use CSS to specify the height and overflow property of the div.

    
    
    
    ...table content...

    This way the div has a fixed height and the browser will add a scrollbar when the content of the div block is too height.

    I have set the height to 15em, which corresponds with 15 * font-height. When using borders, paddings and stuff this height is incorrect. But it can be calculated more properly (in px) for your design.

提交回复
热议问题