是否可以检测浏览器字体大小?当用户从菜单选择中更改字体大小时,是否也可以检测到新的字体大小? 非常感谢大家的帮助。 最好的问候。
最佳答案
Is it possible to detect browser font size?
有点,但很少是个好主意。假设
没有设置字体大小并且没有干扰规则(比如‘body div’):var measure= document.createElement('div');
measure.style.height= '10em';
document.body.appendChild(measure);
var size= measure.offsetHeight/10;
document.body.removeChild(measure);
为您提供 1em 的像素大小。
Also is it possible to dedect new font size when user changes the font size from menu selection?
不是直接的,但是你可以像上面那样经常轮询一个测量器函数。在 IE 上你可以挂起 CSS expression() 的检查,因为当字体大小改变时这些重新计算(在许多其他时间),但这可能不值得(你仍然需要其他浏览器和表达式的轮询器( ) 无论如何都被弃用了)。
关于html - 检测浏览器字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/739940/