[英]bounding box height working in chrome not working in Jsfiddle
我只是制作了一个像打mole鼠的游戏,在指定的时间突出显示了方块,用户不断点击方块。一旦成功单击10次,游戏就结束了。 问题在于该游戏只能在chrome中运行,而不能在jsfiddle中运行。
主要问题在于下面的代码
var addCss = function(oneDivSize,element,rowIndex,colIndex){
element.style.width = oneDivSize+'%';
element.style.height = oneDivSize+'%';
element.style.borderWidth ="1px";
element.style.borderColor ="green";
element.style.borderStyle ="solid";
var boundingRect = element.getBoundingClientRect();
element.style.position ="absolute";
element.style.left =colIndex * boundingRect.width+"px";
element.style.top =rowIndex * boundingRect.height+"px";
};
boundingRect.height返回2像素
但是相同的代码在chrome中可以正常工作。
提前致谢
问候,
亚历克斯
我已经通过用window.innerHeight替换getBoundingBox来解决了这个问题。
问候亚历克斯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.