Why is the window.width smaller than the viewport width set in media queries

后端 未结 7 2040
轻奢々
轻奢々 2020-12-01 09:45

I am quite puzzled and still unsure how to explain this in proper words. So far i\'ve used and set up my media queries with Breakpoint. An used Breakpoint-variable looks lik

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-01 10:09

    follow this link

    function getWindowWidth() {
        var windowWidth = 0;
        if (typeof(window.innerWidth) == 'number') {
            windowWidth = window.innerWidth;
        }
        else {
            if (document.documentElement && document.documentElement.clientWidth) {
                windowWidth = document.documentElement.clientWidth;
            }
            else {
                if (document.body && document.body.clientWidth) {
                    windowWidth = document.body.clientWidth;
                }
            }
        }
        return windowWidth;
    }
    

提交回复
热议问题