79574897

Date: 2025-04-15 10:20:10
Score: 1
Natty:
Report link

You can dynamically calculate and set both row height and font size so that everything fits within the .container. You already did the row height, you can also handle font scaling. – tepalia

Scaling the font-size down together with the row height is actually what I need. I didn't even consider the font-size is holding up the row height from changing.

function updateRowHeights() {
      const rows = tbody.querySelectorAll('tr');
      const totalHeight = container.clientHeight;
      const rowHeight = totalHeight / rows.length;
      const fontScale = 0.5; // 50% of row height

      rows.forEach(row => {
        row.style.height   = rowHeight + 'px';
        row.style.fontSize = (rowHeight * fontScale) + 'px';
      });
    }
Reasons:
  • Blacklisted phrase (0.5): I need
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Matthew Bima