units icon indicating copy to clipboard operation
units copied to clipboard

Incorrect conversion for vertical-align

Open Azmisov opened this issue 2 years ago • 0 comments

For vertical-align, the two numeric values it can take are percentage and length.

  • Length in this case is offset from text's baseline
  • Percentage is offset from baseline as a percentage of line height So to correctly convert them you need to calculate line height. Unfortunately, getComputedStyle for line-height can return "normal" (appears to be "px" for all other cases). Perhaps a way to convert "normal" could be to measure something like:
getCreatedElementHeight(document.body, {
    lineHeight: el_styles.lineHeight, 
    fontFamily: el_styles.fontFamily, 
    fontSize: el_styles.fontSize
});

Though that may not be entirely reliable

Azmisov avatar Jan 17 '23 21:01 Azmisov