我正在尝试计算当前屏幕尺寸的 80% 宽度有多少个像素。
这是我到目前为止所得到的:
setInterval(function () {
width = (window.innerWidth > 0) ? window.innerWidth : screen.width;
var percentWidth = 0.2;
var nWidth = (width - percentWidth) / width;
nWidth = Math.floor((nWidth * 100));
console.log(nWidth);
}, 100);
知道哪里出了问题吗?
最佳答案
窗口宽度的 80%:
window.innerWidth * .8
关于JavaScript计算当前屏幕尺寸的80%是多少像素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20119208/