units
units copied to clipboard
Incorrect conversion for vertical-align
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