I am facing a challenge in setting the height of a parent ul
element based on the included li
's. The issue arises when the CSS property line-height
contains fractional digits, causing inaccuracies in the calculation. This results in the calculated height being either too large or too small, as shown in this example on jsfiddle (1px in Firefox). The discrepancy in height becomes more pronounced in larger lists, sometimes varying by several pixels. Setting the height of the parent ul
can also make it too small for its content.
How can I accurately calculate the height values, particularly when line-height
is involved?