1em = font-size (в px)
20em = 20 * font-size<input type="button" value="нажать (20em в px)" onclick="alert(parseFloat(getComputedStyle(this, '').fontSize) * 20 + 'px')"/> getComputedStyle(this, '').fontSize — это font-size элемента в px, вместо this можно употребить document.getElementById() и т.п. parseFloat() преобразует строку в число20px = 20 / font-size
<input type="button" value="нажать (20px в em)" onclick="alert(20 / parseFloat(getComputedStyle(this, '').fontSize) + 'em')"/>
2 комментария: