Different window.innerWidth between chrome and firefox?

回眸只為那壹抹淺笑 提交于 2019-12-20 05:21:04

问题


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.


回答1:


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())


来源:https://stackoverflow.com/questions/14450874/different-window-innerwidth-between-chrome-and-firefox

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!