跨浏览器的相同文本的不同宽度 [英] different width of same text across browsers

查看:130
本文介绍了跨浏览器的相同文本的不同宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Chrome(/ safari),FF和IE中,文本的宽度呈现不同的形式。 Chrome和FF之间有很大的区别,而FF和IE之间只有很小的差距。您可以通过在浏览器中打开它来查看差异: http://jsfiddle.net/xhx9z/

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.

简单测试:

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

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

宽度的结果是:

chrome/safari: 501
FF: 519
IE: 520


推荐答案

如果您需要将这些元素设置为一定的大小,请不要让浏览器对其进行计算:使用CSS强制您需要的元素。

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.

这篇关于跨浏览器的相同文本的不同宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆