search

Home  >  Q&A  >  body text

javascript - 如何得到因为resize造成的offset

resize之前,我们可以得到某个元素的offset,当浏览器大小改变了(也就是触发了resize事件),这个元素的offset可能会改变,怎样知道它改变了多少?
注意:不通过resize之后计算得来,而是只通过resize这个事件来求offset改变了多少。

巴扎黑巴扎黑2902 days ago390

reply all(1)I'll reply

  • 黄舟

    黄舟2017-04-10 14:27:57

    var height = $(window).height(), //window.innerHeight
        width = $(window).width();//window.innerWidth
    $("ElemtId").css({"height":height},{"width":width});//document.getElementById(id).style.height=height
    

    试试这种方法

    reply
    0
  • Cancelreply