我在动态创建的 DIV 元素上使用 Mootools More 函数“getComputedSize”。它在 Firefox 中运行良好,但在 Google Chrome 中运行不正常:
CSS:
.resultBox {
width: 150px;
height: 100px;
position: absolute;
z-index: 1000;
}
Javascript:
this.resultBox = new Element('div', {
'class': 'resultBox'
});
console.log(this.resultBox.getComputedSize().width);
结果在 FF 中是“150”,但在 Chrome 中结果是“NaN”。
有谁知道如何在 Chrome 中修复此问题而无需将 DIV 编码到 html 中?
提前致谢
亚历克斯
固定:
this.resultBox = new Element('div', {
'class': 'resultBox'
});
this.resultBox.inject(this.container, 'top');
console.log(this.resultBox.getComputedSize().width);
在尝试使用此方法之前注入(inject)元素。
最佳答案
固定:
this.resultBox = new Element('div', {
'class': 'resultBox'
});
this.resultBox.inject(this.container, 'top');
console.log(this.resultBox.getComputedSize().width);
在尝试使用此方法之前注入(inject)元素。
关于javascript - Mootools getComputedSize 在 Chrome 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4286310/