0
在此先感谢。文字宽度在Chrome和Firefox中不同
JS小提琴链接:http://jsfiddle.net/XpPpR/46/
这里是我的代码,
<script src="Hide_3d5b7aca/Hide/jquery-1.9.1.min.js"></script>
<div id="measureText"/>
<script>
$(function() {
text = "1 000 000";
font = {
color: '#282828', fontFamily: 'Segoe UI', fontStyle: 'Normal', fontWeight: 'regular', opacity: 1, size: '13px'
};
var element = $(document).find("#measureTex");
if (element.length == 0) {
var textObj = document.createElement('text');
$(textObj).attr({ 'id': 'measureTex' });
document.body.appendChild(textObj);
}
textObj.innerHTML = text;
if (font != null) {
textObj.style.fontSize = (font.size > 0) ? (font.size + "px") : font.size ;
textObj.style.fontFamily = font.fontFamily ;
}
alert(textObj.offsetWidth);
});
</script>
的文本宽度显示为Chrome和Firefox 57,但在IE它返回的56 为什么呢?以及如何解决这个问题。
这个信息有什么来源? –
@AkbarBasha,请查看这篇文章,例如:http://www.smashingmagazine.com/2012/04/a-closer-look-at-font-rendering/ – IonDen
感谢您的信息 –