1
这是关于更改HTML中元素的top
属性的问题。在iOS设备上设置CSS不起作用
我正在尝试构建一个垂直平移背景图像和垂直对象的游戏。游戏在桌面上正常工作,但在iPhone上,顶级属性不会动态变化。
这是我尝试设置top
blitzbot.bgPanValue.vy += blitzbot.bgPanValue.gravity;
blitzbot.bgPanValue.currentY -= blitzbot.bgPanValue.vy;
var cury = Math.round(blitzbot.bgPanValue.currentY);
document.getElementById("hotDog").style.top = -cury - 300 + "px";
我描绘出的document.getElementById("hotDog").style.top
值的代码和值做change.However,顶部是没有得到设置hotDog
在iPhone上。
最佳, 戒
是否有可能在CSS的其他位置设置顶级属性?使用Chrome检查器查看它是否被重置。 – Lowkase
尝试检查'cury'的确切值,也许它会更改为'undefined'或'NaN'。 – biziclop
它在铬上运行正常。该属性仅在iPhone上有问题。 我使用了'console.log'和控制台报告更改的值。 –