不同的window.innerWidth chrome和firefox之间? [英] Different window.innerWidth between chrome and firefox?

查看:574
本文介绍了不同的window.innerWidth chrome和firefox之间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  html,body {
position:absolute;
width:100%;
height:100%;
margin:0;
padding:0;
overflow:hidden;
}

window.innerWidth 从FX和chrome返回不同​​的数字
FX返回1429而Chrome返回1159,为什么有区别,如何解决它?感谢。

解决方案

这是因为文档的依赖取决于应用程序主体可以使用多少视口。 p>

这将取决于应用程序边界的厚度,以及活动的任何其他插件等。



< a href =http://jsfiddle.net/arunpjohny/KZhjc/2/ =nofollow>此处演示。这将提醒浏览器的宽度,对我来说chrome是给677而firefox是给674

  var body = $(' body')
alert(body.width()+' - '+ body.innerWidth())


html, body { 
     position:absolute; 
     width:100%; 
     height:100%; 
     margin: 0; 
     padding: 0; 
     overflow: hidden; 
}

The window.innerWidth return different number from FX and chrome FX return 1429 while Chrome return 1159 , Why is the difference and how to fix it? Thanks.

解决方案

It because the with of the document depends on how much of the viewport is available for the application body.

It will depend on the thickness of the borders of the application, any other plugins which are active etc.

demo here. This will alert the width of the browser, for me chrome is giving 677 while firefox is giving 674

var body = $('body')
alert(body.width() + ' - ' + body.innerWidth())

这篇关于不同的window.innerWidth chrome和firefox之间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆