How to detect DIV's dimension changed?

后端 未结 25 2905
抹茶落季
抹茶落季 2020-11-22 06:14

I\'ve the following sample html, there is a DIV which has 100% width. It contains some elements. While performing windows re-sizing, the inner elements may be re-positioned,

25条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 06:47

    Pure Javascript solution, but works only if the element is resized with the css resize button:

    1. store element size with offsetWidth and offsetHeight;
    2. add an onclick event listener on this element;
    3. when triggered, compare curent offsetWidth and offsetHeight with stored values, and if different, do what you want and update these values.

提交回复
热议问题