How can I detect wrapping with javascript? [closed]

点点圈 提交于 2020-01-05 08:53:31

问题


I have a load of fixed width divs inside a dynamic width div. The fixed divs all go next to each other and eventually wrap. What I want is to detect if one div ends up on a line on it's own. The only way I can think of for doing this is detecting where the divs wrap but I haven't been able to figure out how. Help is really appreciated.


回答1:


so you want to know if the div is on it's own row?

you can check each div's offsetTop to check against the other div's if they are on the same row. if the div's offsetTop dont match any of the others, then it's on it's own.



来源:https://stackoverflow.com/questions/9838202/how-can-i-detect-wrapping-with-javascript

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