jquery $(window).width() and $(window).height() return different values when viewport has not been resized

前端 未结 4 703
野性不改
野性不改 2020-12-04 07:45

I am writing a site using jquery that repeatedly calls $(window).width() and $(window).height() to position and size elements based on the viewport

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-04 08:16

    Note that if the problem is being caused by appearing scrollbars, putting

    body {
      overflow: hidden;
    }
    

    in your CSS might be an easy fix (if you don't need the page to scroll).

提交回复
热议问题