Set maximum displayed rows count for HTML table

后端 未结 6 1681
情歌与酒
情歌与酒 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:33

    There is no way to do this with only CSS and HTML, you need javascript too. Get the height of the top 15 rows, and limit the height of a wrapping div to that height. Set overflow: auto on the div to get your scrollbars.

    Don't forget to set a default height on the div as a fallback if javascript is turned off.

提交回复
热议问题