Setting a max height on a table

前端 未结 9 1388
猫巷女王i
猫巷女王i 2020-12-29 01:10

I am trying to design a page where there are some tables. It seems that styling tables is much more painful than it ought to be.

The problem is the following: The ta

9条回答
  •  爱一瞬间的悲伤
    2020-12-29 01:45

    In Tables, For minimum table cells height or rows height use css height: in place of min-height:

    AND

    For Limiting max-height of all cells or rows in table with Javascript:

    This script is good for horizontal overflow tables.

    This script increase the table width 300px each time (maximum 4000px) until rows shrinks to max-height(160px) , and you can also edit numbers as your need.

    var i = 0, row, table = document.getElementsByTagName('table')[0], j = table.offsetWidth;
    while (row = table.rows[i++]) {
        while (row.offsetHeight > 160 && j < 4000) {
            j += 300;
            table.style.width = j + 'px';
        }
    }
    

    Source: HTML Table Solution Max Height Limit For Rows Or Cells By Increasing Table Width, Javascript

提交回复
热议问题