Autosize HTML table cell height based on content when rowspan is involved -


is there way autosize html table height based on content? if it's cell (or cells) next neighbor cell multiple rowspans.

e.g. if have table (cell on right has rowspan="2" , height of cell content = 600px, in each cell on left height of cell content = 150px):

cells evenly spaces

there gap between 2 cell consents on left because cells autosized height. i'd this:

cell height adjusted content

where top cells automatically collapse cell content height. there anyway achieve this?

this sets last row of cells correct height (demo):

function grow(td) {     var table, target, high, low, mid;      td = $(td);     table = td.closest('table');     target = table.height();     low = td.height();      // find initial high     high = low;     while (table.height() <= target) {         td.height(high *= 2);     }      // binary search!     while (low + 1 < high) {         mid = low + math.floor((high - low) / 2);         td.height(mid);         if (table.height() > target) {             high = mid;         } else {             low = mid;         }     }      td.height(low); }  $('tr:last-child td').each(function() { grow(this); }); 

​ should trivial convert plain javascript.


update: more complicated tables, you'll want replace last line (demo):

$.each($('td').get().reverse(), function() { grow(this); }); 

​ idea call grow() on every cell, starting last row , working upwards.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -