different width of same text across browsers

断了今生、忘了曾经 提交于 2019-12-11 19:54:37

问题


The width of text is rendered differently across Chrome(/safari), FF and IE. There is a quite big difference between Chrome and FF, while only small gaps between FF and IE. You can see the difference by opening this in browsers: http://jsfiddle.net/xhx9z/

Does anybody know if there is any way to reduce the gap so that the width are close across browsers.

Simple test:

<span>this is a test of text width and see the difference across browsers<span>

$(document).ready(function() {
    alert($('span').width());
});

The results of width are:

chrome/safari: 501
FF: 519
IE: 520

回答1:


If you need these elements to be a certain size, don't let the browser compute it: force what you need it to be using CSS.




回答2:


Rendering text depend from Operating system settings, used browser. And always will be different. Try another way to solve the preceding problem.



来源:https://stackoverflow.com/questions/22530190/different-width-of-same-text-across-browsers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!