小编jon*_*mez的帖子

Chrome的设备模式中的window.innerWidth

在谷歌浏览器的设备模式下,window.innerWidth返回什么?它是设备的视口(加上任何滚动条)?

我为设备的宽度x高度(页面顶部的尺寸 - 设备的视口?)和window.innerWidth x window.innerHeight(浏览器的视口?)获得了不同的值.这应该发生吗?

这是我得到的图片和我使用的代码.

图片

<!doctype html>
<html>
<head></head>
<body>
<script>
var image;

window.onload = function() {
  image = document.getElementById("img");
  checkWindowSize();
  window.addEventListener('resize', function(event){
    checkWindowSize();
  });
}

function checkWindowSize() {
  var width = window.innerWidth,
      height = window.innerHeight;

  console.log("window.innerHeight: ", window.innerHeight, " window.innerWidth: ", window.innerWidth);
}
</script>

<img id="img" class="vid-img-filter" src="http://i.imgur.com/jkhFJMn.jpg" alt="">
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

mobile google-chrome viewport

11
推荐指数
3
解决办法
8704
查看次数

标签 统计

google-chrome ×1

mobile ×1

viewport ×1